Added missing fclose call.
Set proper sizeof to endianess flip.