Use with so the file gets closed afterwards
PEP8 fixes
Merge pull request #1 from legoktm/master

PEP8 improvements & resource leaking prevention