In Python, you can't delete text from files. Instead you can write to a file.
The write function effectively deletes whatever is in the file and saves the file with the string you pass as arguments.
Example
open_file=open("some file","w")
open_file.write("The line to write")
Now the file has the line "The line to write" as the contents.
Edit
The write function more precisely writes over from where the cursor. When you open in w mode, the cursor is at the front of the file and writes over everything in the file.
Thanks bli for pointing that out.