Make sure to close the file on error.
Merge pull request #20 from unknownbrackets/file-close-err

Make sure to close the file on error