# woc3.py
# Written by Todd Wareham for CS 2500
"""
Given the name of a text file and a word as command-line arguments, prints 
 the number of occurences of that word in the file.
"""

import sys

if len(sys.argv) != 3:
    print "usage: python", sys.argv[0], "filename word"
    sys.exit(1)

f = open(sys.argv[1], "r")
line = f.read()
f.close()

count = len([x for x in line.split() if x == sys.argv[2]])

print "The word \"", sys.argv[2], "\" occurs ", count, "times in file \"", \
      sys.argv[1], "\""

