File handles are now properly closed.

Fixes #899.
Merge pull request #900 from jrrideout/issue-899

File handles are now properly closed.