f = open('myfile.txt')
result = {}
for line in f:
    word, count = line.split()
result[word] = int(count) + result.get(word, 0)
f.close()
print('\n'.join(list(result.items())))
Python summing frequencies in a file