trim trailing space from lines as well