Just trim() instead of replacing *all* whitespace.

Thanks @agueganno