Previously, if tail was == 0, and we wrote exactly enough bytes to the end of the buffer, then head would end up at 0 as well. This would make the buffer instaneously empty, as head == tail.