Ensure file handle is closed by using with statement
Merge pull request #288 from svisser/patch-2

Ensure file handle is closed by using with statement