#!/usr/bin/env python

# A skeleton pretty-printing file which reads in an integer and a
# file and creates a list of all the words in the file.  This program
# then prints each word to standard out.

# Make the system namespace available.
# We use the argv member of sys to get
# the command-line arguments
import sys

# Python uses whitespace for control.  This throws a lot of people off
# at first, but over time, one finds it incredibly natural. Read this:
# 1. <http://weblog.hotales.org/cgi-bin/weblog/nb.cgi/view/python/2005/02/19/1>
# 2. <http://www.secnetix.de/~olli/Python/block_indentation.hawk>
def main():
    
    # grab the first argument and make it an integer
    # Note that argv[0] contains the program name
    L = int(sys.argv[1])

    print "You are requesting %s character display" % L

    # create a file handle to the input
    fin = open(sys.argv[2])

    # read() returns the input as one string.
    # split() is a method of string.  By default it tokenizes the
    # input using *whitespace* as a delimeter
    # now words is a list of strings
    words = fin.read().split()
    
    print "The list of words is:"
    print
    
    # cycle through the words and print them out, each on its own line
    for word in words:
        print word



# read <http://effbot.org/pyfaq/tutor-what-is-if-name-main-for.htm>
if __name__ == '__main__':
    main()

                
