Great Solution! Overall this seems the most balanced approach.
I also thought that once a file is opened…
is it loaded entirely on the RAM or just a chunk of it ?
If the first is true, then using backspace or rewind and re-reading shouldn’t take much time…
but I believe this is compiler-dependent so better don’t make assumptions!