Fixed input validation issue

Now properly removes trailing whitespace