Wait, No criticism was meant NogDog - I wasn't challenging your solution - it's very tight. All I meant was that I think the OP was looking for a way to edit exactly one line in a file without having to read in all the lines and then write out all the lines. (Especially in this situation, he's only changing one byte.)
I have sometimes wished I could say:
fopen
fread line 56
alter string
fwrite line 56
fclose
That would be efficient from an I/O perspective - especially on a very large file. But instead, as far as I know, the only way to edit one line in a text file from PHP is to read in all the lines, make the change, and then write out all the lines.