#How to add to a file using the read and flush method #this is nice, but not "functional" enough. def main(): carlist = [] with open('/home/isqsdac/Desktop/workspace/l3_1/carlist.txt', 'r') as f: for line in f: #iterate over each line in the file. carlist.append(line.rstrip()) carval = input('Name a car:') while carval != "done": carlist.append(carval) carval = input('Name a car (or type done to end): ') #let's save to a file with open('/home/isqsdac/Desktop/workspace/l3_1/carlist.txt', 'w') as f: for c in carlist: f.write(c) f.write('\n') main()