Reading and writing text files is done with open(), preferably in a with block that closes the file automatically. The mode (r, w, a) indicates read, write or append, and you should specify encoding='utf-8'. The w mode overwrites the existing contents.
Example
with open('notes.txt', 'w', encoding='utf-8') as f:
f.write('hello')