When stdout is a tty, use stderr to ensure there is a newline before
the shell prompt.
(Modified) patch from Yair K.:
If the used selection does not end with a newline, then:
A) If 'xsel -o' than the command prompt may overwrite the last line (depends
on $PS1, shell, etc. but I think quite likely to happen)
B) 'xsel -a -o -i' doesn't display the last line (on Linux at least). The
last line will still exist after appending, but it isn't displayed. This is
(I suspect) because stdout is line-buffered, so stdout isn't flushed yet.