Fixed bugs on reading a file.