fix the NullPointException caused by the end of the Read