fixed a bug with file reading