trim trailing whitespece and newline