Fixed implementation of reading from a file.