prog12_8.py

with open("greeting.txt", "r", encoding="utf-8") as file_obj:
    while True:
        s = file_obj.read(8)
        if s == "":
            break
        print(repr(s))

# プログラム12-8(ファイルの終わりを判断)