Remove trailing newlines from pasted text

Some applications, such as Chrome, implicitly adds a newline to copied
text, which can cause command lines to be inadvertently executed.  To
alleviate this problem, this patch removes all trailing newlines from
pasted text.

Signed-off-by: Morten Hustveit <morten.hustveit@gmail.com>