Since you don't say exactly what the problem, we can't say exactly what caused it. A possibility (and it's only a possibility, of course) would be that you are doing strict equality checking; a string is equal, but not strictly equal, to an identical string with one or more spaces appended.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day