fix bug in getting read to end in readbuffer where read == write position