Fixed the writing to binary.