I have a simple bit of python code that opens two files, and loops through each string in one file, looking for the matching string (or part of it) in the other file. If it finds it, it should write that line to file. For some reason it isn't iterating through. Here is my code:
out = open("outputfile.txt", "w")
with open("inputfile1.txt", "r") as f:
with open("inputfle2.txt", "r") as map:
for line in f:
for mline in map:
if line[0:6] in mline:
out.write(line)
For some reason the resultant output file only contains one line. I have checked the line and it is correct, so the code is doing what I want but the loop is not iterating through both files for some reason. I know there's an obvious solution to this but hours of searching and fiddling with my code haven't yielded any results.