change according to instruction below

1.  There is a bug where the last character in the word doesn't show up! Please fix this error.
2.  There is a bug where the space in the words do not appear correctly. Please fix this error.
3. The current code is creating lots of global variables; we don' t like this. Use what you learned about immediate functions to wrap all of this code in a single immediate function so that you don't introduce any global variables.