Manage last newlines at the end of the selection

Fixes #4