Move back and forward reading a file

This is not specified by the standard, and this is managed by the OS. With the commonly used OS’s, just opening a file does not load any of the content in RAM.The parts of the files that are explicitly read afterwards are cached in RAM, at least as long as:

  • the file is not closed (so, the rewind option is actually better than closing/reopening the file)
  • the OS does not need to reclaim the space occupied by the cache

If your file is not too big, it is reasonable to assume that it will stay in cache between the 2 passes, therefore that the 2nd pass will be much faster than than the 1st pass