import pywikibot

def check_wiktionary_existence(title):
    site = pywikibot.Site("ku", "wiktionary")
    page = pywikibot.Page(site, title)
    return page.exists()

def save_to_file(word, exists):
    with open("wiktionary_output.txt", "a", encoding="utf-8") as file:
        file.write(f"{word}: {'heye' if exists else 'tune'}\n")

# Lîsteya peyvan ji dosyeyê bixwîne
word_list_file = "word_list.txt"  # navê dosyeyê
with open(word_list_file, "r", encoding="utf-8") as file:
    words_from_file = [line.strip() for line in file.readlines()]

for word in words_from_file:
    exists = check_wiktionary_existence(word)
    save_to_file(word, exists)

print("Kontrolkirin bi dawî bû. Encam di dosyeya 'wiktionary_output.txt' de hatin tomarkirin.")