check handle validity when closing a file

This eliminates an assertion under Windows that occurs when an archive cannot be
opened.
Merge pull request #80 from sergiud/master

Check whether file handle is valid