for w in open('filename.dat').read().split():
    if w in count:
        count[w] += 1
else:
    count[w] = 1
for word, times in list(count.items()):
    pass
Counting the number of unique words in a document with Python