with open('test.dat', 'w') as handle:
    while True:
        name = input('Enter a name: ')
if not name:
    break
handle.write(name + '\n')
Writing to a File with Python -- ''While not done:" Confusing Me