whiteflags point is that your code is not portable. There are real-world machines that are not little endian. Your file format is therefore machine dependent.

More significantly, the output...