I think the code is correct. To implement smoothing, you want to add 1 to the count of every word, regardless of whether it appears in the training data or not.
That is to say, a word that appears once should get a count of 2, and word that doesn't appear at all should get a count of 1.