Ensure file handles are closed using with statement
Merge pull request #169 from svisser/patch-1

Ensure file handles are closed using with statement