written is uninitialized when count < 0.