# replaceword.py
# Written by Todd Wareham for CS 2500
"""
Given the name of a text file and words w1 and w2, computes and prints the
 version of the file on which all occurencesd of w1 (possibly as substrings
 of longer strings) are replaced by w2.
"""

import sys

if len(sys.argv) != 4:
    print "usage:", sys.argv[0], " filename oldword newword"
    sys.exit(1)

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

print line.rstrip().replace(sys.argv[2], sys.argv[3])

