handle eof in receive