For counting the number of lines in a file, you could use something similar to this:
$file = file("yourfile.txt");
$number_of_lines = count($file);
Then $number_of_lines would contain the number of lines in your file. As for deleting a line, you could use the $file array holding the file, unset($file[<<your line number here>>]);, then use a foreach($file as $line_num => $text) to write it back out to your file. Hope this helps,
-Josh B