''' printwords.py Jeff Ondich, 22 April 2009 This program prints the "words" found in a file specified by the user. Here, a "word" is a contiguous block of non-whitespace characters. ''' import sys if len(sys.argv) != 2: print 'Usage: %s filename' % sys.argv[0] sys.exit(1) fileName = sys.argv[1] theFile = open(fileName, 'r') for line in theFile: line = line.strip() # removes whitespace from ends words = line.split() # create a list of whitespace-delimited chunks for word in words: print word theFile.close()