I have a file named $dir and a string named $line, I know that this string is a complete line of that file but I don\'t know its line number and I
$dir
$line
Another approach is to read the file line by line until you find a match, then truncate the file to that point, and then append the rest of the lines.