human
Prepend a line to an existing file in Python
assistant
Here is some code to prepend the line '#test firstline\n' to the contents of file 'infile' and save as the file 'outfile'

open('outfile', 'w').write('#test firstline\n' + open('infile').read())

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.