import fileinput import sys for line in fileinput.input(['./ampo.txt'], inplace=True): sys.stdout.write('EDF {l}'.format(l=line))