Ensure file handles are closed using with statement
Renamed variables for consistency within file
Merge pull request #4 from svisser/patch-1

Ensure file handles are closed using with statement thanks @svisser