Updated thin.py to use temporary file and rename.