[python] Python write line by line to a text file