style cleanups
 - use open file handle in try:
 - Misc PEP8 cleanups