Almost all the time that I play with text files directly I use the following
$fp = fopen( $file, 'r' );
while( !feof( $fp ) ) {
$line = str_replace( "\n", '', fgets( $fp ) );
}
this function cuts a little bit of that out. Also abstracts the logic out into a single place so that if (god forbid) I ever have to port any of my code over to a windows machine I just have to change the "\n" to "\r\n" in the function rather than every place I read a file.
There's two points, I'll try to think up some more.
...
...
Aha! Yes, everyone knows that bugs are scared of functions called fgetsnl, so, if I have a function by that name in my code all the bugs will be scared away and I'll have bug free code! I knew there was another reason 😉