Close various files when finished writing to them. This avoids ResourceWarnings on Python 3, and better supports doctests under PyPy.
Typo and indentation corrections. One more resource warning.
Unify three checks for a file being changed into one function. Note that python < 3.3 raise IOError if a file is not found, while python >= 3.3 raise FileNotFound, a kind of OSError. EnvironmentError is a common superclass on all versions and in fact is where `errno` is defined.
Merge pull request #180 from NextThought/master

Close various files when finished writing to them; fixes ResourceWarnings and some PyPy uses.