Update putfile.py

Use 'with' to open output file.