from sys import argv
replacement_table_file, infile, outfile = argv[1:4]

replacement_table = [i.strip().split(' ') for i in open(replacement_table_file, 'r').readlines()]

text = open(infile, 'r').readlines()
for index, line in enumerate(text):
    for entry in replacement_table:
        text[index] = text[index].replace(entry[0], entry[1])

open(outfile, 'w').writelines(text)
