error checking in read; supports empty files and handles files missing final eol