Deleting data in file before pointer

fseek($fp, 7); // move to the 7th byte

$data = fread($fp, 10);  

After the program is done I want it to be able to delete the bytes that have been read in the beginning of the file before the pointer. Is this possible? If not, could I do this with each line instead and how would I do this in both scenarios?

My problem is I have large file so I cannot open the file an turn each line into a variable. I need the file to scan/read the first N bytes or lines in the file, do some process for those bytes/lines and then delete those bytes and reread the file again from the beginning doing this process over and over again until the file is empty.

Any help guys or point me in the right direction?

Instead of reading one line, deleting that line, writing the remainder to a file -
reading one line, deleting that line, writing the remainder to a file -
reading one line, deleting that line, writing the remainder to a file -
reading one line, deleting that line, writing the remainder to a file -
reading one line, deleting that line, writing the remainder to a file -
reading one line, deleting that line, writing the remainder to a file -
reading one line, deleting that line, writing the remainder to a file -
reading one line, deleting that line, writing the remainder to a file -
reading one line, deleting that line, writing the remainder to a file -
reading one line, deleting that line, writing the remainder to a file -

You get the idea.

Why not just read each line, then delete the file when you’ve done that?

Yeah I figured something out though it wasn’t exactly what I wanted but it’ll do until I find a better way.