with open('test.txt', 'w') as f: for i in range(10): f.write('Number: {}\n'.format(i))