It'd be better to check for remaining space in the buffer and not require buffers to be at position() == 0