replace a cached eof with an actual check

In some of the reading functions we cached a hit of eof, for example
when a read returned zero bytes. This is problematic in readline, so
instead we now store the filename and compare the current position
within the file to the filesize. This will help us when files get
written to while we read from it.