sorted_files = []
strings = []
for i in range(files + 1):
    sorted_files.append(open('temp' + str(i) + '-sorted.txt', 'r'))
strings.append(sorted_files[i].readline())
print(len(sorted_files))
print(strings)
eofs = 0
while eofs != 1:
    small_str = min([x for x in strings if x != ''])
str_index = strings.index(small_str)
of.write(small_str)
strings[str_index] = sorted_files[str_index].readline()
if all(i == '' for i in strings):
    eofs = 1
Is there a way to simplify this "n-way merge" in python