added eof read section of readpacket