I think the problem (word,cnt) = line.strip().split('\t') #\t
The split() method returns a list and tries to assign it (word, cnt) , which does not work, because the number of elements does not match (maybe sometimes there is only one word).
Maybe you want to use something like
for word in line.strip().split('\t'): mydict[word] = mydict.get(word, 0) + 1
If you have problems with empty list items, use list(filter(None, list_name)) to remove them.
Disclaimer: I have not tested the code. In addition, this only applies to your second example.
source share