Hi
thanos1983,
why not load the data into an array and access the array when ever you want instead of keeping the fh open
There can be many reasons for not doing that. The most compelling one, which I face almost daily, is that my files often have hundreds of millions of lines. They simply do not fit in memory. And the files I am writing to usually have similar size.
Even with smaller but still quite large files, it is usually faster to read the file line by line and process each line, rather than copying the data into an array, process each item of the array and then write back the modified array lines