import json ar = [] with open('censorship.txt', encoding='utf-8') as read_file: for i in read_file: n = i.lower().split("\n")[0] if n != "": ar.append(n) with open('censorship.json', "w", encoding='utf-8') as write_file: json.dump(ar, write_file) # with open('name_dict.txt', encoding='utf-8') as read_file: # for i in read_file: # n = i.lower().split("\n")[0] # if n != "": # ar.append(n) # with open('name_dict.json', "w", encoding='utf-8') as write_file: # json.dump(ar, write_file)