Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
matias stuff
infile = open('infile.txt', 'r')
content = infile.readlines() #reads line by line and out puts a list of each line
infile.close() #close the input template file
#here is where you change
content[1] = "foo \n" #replaces content of the 2nd line (index 1)
outfile = open('outfile.txt', 'w') #open up an output file
outfile.writelines(content) #write the content to the file
outfile.close() #close the file (not realllly necessary but good practice)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment