# Challenge 72 - Read Your Journal
from pathlib import Path

path = Path("journal.txt")
if not path.exists():
    print("Journal file not found.")
else:
    lines = path.read_text(encoding="utf-8").splitlines()
    entries = [line.strip() for line in lines[1:] if line.strip()]
    keyword = input("Search term: ").strip().casefold()
    matches = [(number, text) for number, text in
               enumerate(entries, 1) if keyword and keyword in text.casefold()]
    if matches:
        for number, text in matches:
            print(f"{number}. {text}")
    else:
        print("No matching entries.")
