Is it possible to have the following logic of a for loop in python?:
with open("file_r", "r") as infile, open("file_1", 'w') as outfile_1, open("file_2", 'w') as outfile_2:
for result in re.findall('somestring(.*?)\}', infile.read(), re.S):
for line in result.split('\n'):
outfile_1.write(line)
for result in re.findall('sime_other_string(.*?)\}', infile.read(), re.S):
for line in result.split('\n'):
outfile_2.write(line)
I'm asking because the result of the first foor loop are written to the "outfile_1" file, but the results of the secund loop are empty in the "outfile_2" file.