output_files = [(os.path.join(outpathDirTest, fname) + '.txt') for fname in
    pureResponseNames]
for filename in range(output_files):
    with open(filename, 'w') as f:
        f.write('This is a test of file nr.' + str(i))
IOError: [Errno 24] Too many open files: