Only match command output end in last line (fixes #3)

Also make preceding linefeed optional