write to binary file fixed