myFile = open('today','r')
ips = {}
for line in myFile:
parts = line.split()
if parts[1] == 'Failure':
ips.setdefault(parts[0], 0)
ips[parts[0]] += 1
of = open('failed.py', 'w')
for ip in [k for k, v in ips.iteritems() if v >=5]:
of.write(k+'\n')
Check out setdefault, it makes the code a little more legible. Then you dump your data with the file object's write method.