How to remove the line in the big file?

Good day!
I have a lot of reference files (in each file in the order of 50K lines), the point is that I have the parser walks along each link, and after he passed through it, preferably the line with this link from a file to delete, not to interfere. But the only algorithm I found in the Internet says that the entire file will have to unload in the array, from array to remove the desired rows, and then re-record all the contents of the array to a file. Is there no other way? The fact that my parser can fly so many different throw exception, and work will immediately cease. That is, to form the array during operation, and at the end it write to the file will not work, you need each iteration to do the overwrite, and that will take a lot of time and memory. Maybe something else to think of?
Thank you in advance!
March 12th 20 at 08:12
2 answers
March 12th 20 at 08:14
Abstract the essence of the issue:

for this it is better to use a database - even file. Your way you spend a lot of resources for a simple operation.
March 12th 20 at 08:16
In fact, there is such a wonderful design..

try {}
catch(\Exception $e) {}
finally {}

which allows you to handle exceptions (the catch section)
or you can do something regardless of whether all of the code (section finally)

Find more questions by tags PHP