Fixed infinite loop when accessing file with an offset which equals to the file size