Fixed read past end of file issue.