I've noticed you were useing to_ne_bytes not to_le_bytes in the writer. This should fix that.
to_ne_bytes
to_le_bytes