#! /usr/bin/python fout = open('output.txt', 'w') line1 = "Hussein Abdel-Wahab\n" fout.write(line1) line2 = "ODU\n" fout.write(line2) fout.close() print try: fin = open('output.txt') for line in fin: print line, #, no newline fin.close() except: print 'Something went wrong.' import sys print def linecount(filename): count = 0 for line in open(filename): count += 1 return count print linecount('output.txt') #print linecount(sys.argv[1]) print # reads in the text file whose name is specified on the command line, # and reports the number of lines and words def checkline(): global l global wordcount w = l.split() wordcount += len(w) wordcount = 0 f = open('files.py') flines = f.readlines() linecount = len(flines) for l in flines: checkline() print linecount, wordcount