import os
#add expand
src_file = raw_input("source path: ")
expand = raw_input("expand: ")
#rename
bak_src = src_file + ".bak"
os.rename(src_file, bak_src)
input = open(bak_src)
#print input
output = open(src_file, 'w')
while True:
line = input.readline()
if line:
# print line;
line = (line.strip()) + expand
# print line
output.write(line)
output.write("\n")
else:
break
output.close()
input.close()
print "OK"
|