import json # Using readlines() fileslist = open('listoffiles.txt', 'r') Lines = fileslist.readlines() count = 0 linesarray = [] matchingfilepaths = [] fileoutput = open('matchinglines.txt','a') # Strips the newline character for line in Lines: # print(line) line = line.strip('\n') linesarray.append(line) # with open("mergedjson.txt") as file: # if line in file.read(): # print("true") # else: # print(line) with open('mergedjson.json') as jsonfile: data = json.load(jsonfile) for f in data: # print(f) file = f["debrispath"] if line == file: # print("true") matchingfilepaths.append(line) fileoutput.write(line+'\n') # print("====") print(matchingfilepaths) # with open('mergedjson.json') as jsonfile: # # print(line) # if "karen" in jsonfile: # print("True") # # else: # # print(line) # # print(line.strip()) # # print("Line{}: {}".format(count, line.strip()))