no access to filesystems so this newsgroup is not the best place to ask.
That said, if I were writing a php program as you've described then I'd
just open the file to "a" (append) and add data as necessary. Reading
isn't really a problem since you can specify the size of the data you'd
like to read and read the "large" file in chunks, discarding sections
you no longer need.