Fix the write integer function to handle zero correctly.