You cannot kill all kittens, because in order for PHP to get the next line of the file, it must know the position of the file pointer from the previous line that was removed. You are only promoting an iterator that maintains a link to an object file.
In addition, it is bad practice to open such a file; you must have a variable to save it and close it when done.
source share