verbs = {'dislikes': 'blue', 'knows': 'black', 'likes': 'red'}
for s in open('/tmp/infile'):
    s = s.strip()
for verb in list(verbs.keys()):
    if s.count(verb) > 0:
        print(s.replace(verb, '->') + ' ' + verbs[verb] + ';')
break
Put bar at the end of every line that includes foo