Ensure file is closed properly

If generating a bin file (second half of conditional), make sure the file is closed
(Also fix spelling in comment)