with open('DATA.txt') as reader, open('newfile.txt', 'w') as writer: for index, line in enumerate(reader): if index % 20 == 0: writer.write(line)