Switch print to message and remove trailing whitespace