with open("notes.txt", "r", encoding="utf-8") as file:
text = file.read()Line-by-line explanation
openrequests notes.txt."r"means read mode.- UTF-8 explains how text characters are stored.
as filenames the handle.read()loads the text.
print(text)Line-by-line explanation
- The file has already been closed safely.
textcontains its contents.- Print displays those contents.