Fixed the trailing spaces issue in reverse words.