fix some bugs when try to read a file