with open("test.txt", "a") as myfile: myfile.write("appended text") # [Petter] [so/q/4706499] [cc by-sa 3.0] $