Properly close file on exceptions. Fixes #8 (ouch).