Create a "with" block where you open the file in 'a+' mode. Put the cursor on top of the file. Read the file storing its content in a variable, put the cursor on top of the file, write the content, write the content.