#!/usr/bin/env python3

import os      # miscellaneous operating system interfaces

myText = "However fast you may be able to think,\nit is not fast enough."
f_out = open("output.txt", "w")       # output to file
f_out.write(myText)
f_out.close()                         # closing stream

os.system("cp output.txt input.txt")  # copy files

f_in = open("input.txt")              # reading is the default
print("# f_in :\n", f_in.read())      # file to string --> print
f_in.close()

print()
with open("input.txt", "r") as g_in:  # open with 'with'
  lineCount = 0
  for line in g_in:                   # reading line by line
    lineCount = lineCount + 1
    print(f'reading/printing line {lineCount:3d} ',line)

# cleaning up
if 1==2:
  os.remove("input.txt")
  os.remove("output.txt")
