Update collapse-into-one-line

So that it doesn't pad the head and tail of the line with spaces,
and don't add a new-line at the end.