#TeCoEd @dan_aldred
#Writing data to a text file
#12/04/2013
import time

list = []
times = input("How many lines of data do you wish to add to the file? ")

for i in range(times): 
    file_text = raw_input("Please enter your line of data: ")
    list.append(file_text) #adds the data to your list
    print list #checks the data has been added to the list

# def, opens the file called 'test' in write mode w
# for each of the items i, in the list it writes them to the file with a new line \n
# close the file called test .close
    
def write_to_file(x): 
        file = open("test.txt", "w") #test.txt is the name of the text file the program writes to
        for i in list:
            file.write(i+'\n') #don't forget the ne line '\n'
        file.close()
        print "Your data has been added"

write_to_file(list)

time.sleep(3)
 



