The problem is that you are reversing the words' character order using the same Stack. So, this is what is happening:
hello world is entered
You take hello and put it on a stack in reverse order...