It depends on the size of the file, the method you would want to use.
It sounds like you're doing a database function -- you should try SQL.
In the meantime, I would load the file into a variable, and use str_replace.
That would be really fast for small files.
If not, load the file 4k at a time, and write blocks in 4k until you find the beginning of the string... take the string out, and keep writing. It would only take two file pointers, one loop, and 50uS.
Michael