Using pycham Compiler python project: untitled2 type pure cofiguration: script path - C:\...\Desktop\PSCgroup\4-pyCham\2-samples\prog_email\Scripts\python.exe python interpretor - C:/.../Desktop/PSCgroup/4-pyCham/2-samples/untitled2/file1_progemail.py ---------------------------------------- Source code, python file: file1_progemail.py -------------------------------------------- # Python program to mail merger # Names are in the file names.txt # Body of the mail is in body.txt # open names.txt for reading with open("C:\\_NF/names.txt",'r',encoding = 'utf-8') as names_file: # open body.txt for reading with open("C:\\_NF/body.txt",'r',encoding = 'utf-8') as body_file: # read entire content of the body body = body_file.read() # iterate over names for name in names_file: mail = "Hello "+name+body # write the mails to individual files with open(name.strip()+".txt",'w',encoding = 'utf-8') as mail_file: mail_file.write(mail) -------------------------------------------------- output, after debug and run the Resultat ------------------------------------------------------ Process finished with exit code 0 (0 err0r)