I didn't do this, but you should trim first. I believe tweets can end with trailing whitespace.