##Name: Wurong Weng
##MacID:wengwr
##Student Number: 1224989
##Date: Feb. 6, 2013

f = raw_input("Please enter the name of a text file: ")
infile = open(f, 'r')
llist = infile.readlines()
infile.close()

lines = len(llist)
words = 0
characters = 0

for i in range(lines):
    words += len(llist[i].split())
    characters += len(llist[i].strip('\n'))

outfile = open("wc_output.txt", "w")
outfile.write("x="+str(lines)+'\n')
outfile.write("y="+str(words)+'\n')
outfile.write("z="+str(characters)+'\n')
outfile.close()

print "The output was written in the file named 'wc_output.txt'."


##Design Question
##Obviously, the best way is reading the file once. it is because if you were working
##with a big file, the time taking by reading file three times would be three times
##longer than reading it once.

##Test Plan
##1.No, it is not since the process are the same for both small files and big files. The only
##  difference is that the big file may take longer time to work through.
##2.Yes, our results match the valus of Microsoft Word's.
