handle error in readbytes