removing trailing spaces before redirection