Currently, the write buffer is not reused when it gets full. Switching to a ring buffer would probably be better.