Q:

Removing duplicate lines from a file

I may be going in to wrong direction here so looking for some assistance.
Basically just now, I have a script that opens up a log file and picks out any lines that match a value. With these lines, I then check to see if a key in a dictionary is found and then prints the line. 
I'm not wanting it to print every line, just if it matches once.
So far I have this but can't seem to break in order to only show one match
For this example, my syslog file is:
PHASE 1
PHASE 2
PHASE 2

Code:
phase_dict = {
"PHASE 1": "Phase 1 completed successfully: ",
"PHASE 2": "Phase 2 completed successfully: ",
}

with FileReadBackwards('syslog', encoding="utf-8") as frb:
    for line in frb:
        if re.findall('first_match', line):
            for key,value in phase_dict.iteritems():
                if re.search(key, line):
                    print value + line.rstrip()

My output shows:
Phase 2 completed successfully: PHASE 2
Phase 2 completed successfully: PHASE 2
Phase 1 completed successfully: PHASE 1

I'm trying to get it to only show one match for each.
Expected output:
Phase 2 completed successfully: PHASE 2
Phase 1 completed successfully: PHASE 1

I'm not sure if I'm going down the best route in going through the dictionary and using the for loops 
Any help would be appreciated
Cheers!

A:

With no knowledge of what FileReadBackwards is... 

You can just keep a set of seen phases. 
dict supports random access, so there's no need to iterate over them, much less use regex on them.

from __future__ import print_function

seen = set()
with FileReadBackwards('syslog', encoding="utf-8") as frb:
    for line in frb:
        line = line.strip()
        if line not in seen and line in phase_dict:
            seen.add(line)
            print(phase_dict[line] + line)

