python read and write to file code example
Example 1: python file reading
fin = open("NAME.txt", 'r')
body = fin.read().split("\n")
line = fin.readline().strip()
Example 2: python output to text file
$ python my_program.py > output.txt
fin = open("NAME.txt", 'r')
body = fin.read().split("\n")
line = fin.readline().strip()
$ python my_program.py > output.txt