"""
Base file reading example.

This example uses:
- classic open/close of file
- while loop with walrus operator (Python 3.8).

"""
if __name__ == '__main__':
    file = open("../files/don-diego.txt", "r", encoding="utf-8")
    # Read the file contents line by line using the walrus operator
    # (introduced in Python 3.8)
    # While the line read is not empty, you're not at the end of file.
    while line := file.readline().strip():
        # Lines contain caret return. Using `.strip()`
        # removes spaces and caret returns at the start and end.
        print(f"{line}")
    file.close()
