fixed bug of not read file when is at end of file