Open the file in write ('w') or read-write ('r+') mode.
Modify the content in Python.
Write the changes back using .write().
Save automatically when file is closed.