>this doesn't work. It will still write the new line after the line (I matched). Everytime I read a line from a file, the $fd gets incremented, so when I say fwrite, $fd is already pointing to the next line in the file? Any suggestions as to working around this? I can't rewrite the entire file (design time controls on page, they wouldn't work if I did). As soon as I fix the Cascading Style Sheet line, I want to get out of the file. Might not be fast, but it seems that if you can't go back then you have to start over again. So in the first run read and count the lines and when you found the one start reading again and then you know where to do it. bye Fabi -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php