Write data to a file in Python,f.close()