Any reason you're removing spaces from the middle of a word. Would `strip` have worked here instead?