#TODO: Create a letter using starting_letter.txt 
#for each name in invited_names.txt
#Replace the [name] placeholder with the actual name.
#Save the letters in the folder "ReadyToSend".
    
#Hint1: This method will help you: https://www.w3schools.com/python/ref_file_readlines.asp
    #Hint2: This method will also help you: https://www.w3schools.com/python/ref_string_replace.asp
        #Hint3: THis method will help you: https://www.w3schools.com/python/ref_string_strip.asp
        


with open("Intermediate/D024_Files_Directories_and_Paths/Mail Merge Project Start/Input/Names/invited_names.txt") as file:
    names = file.read()
    name_list = names.split("\n")
    
with open("Intermediate/D024_Files_Directories_and_Paths/Mail Merge Project Start/Input/Letters/starting_letter.txt") as file:
    letter = file.read()
    
    for name in name_list:
        with open(f"Intermediate/D024_Files_Directories_and_Paths/Mail Merge Project Start/Output/ReadyToSend/letter_for_{name}.txt", mode="w") as file:
            new_letter = letter.replace("[name]", name)
            file.write(new_letter)