Only remove trailing newlines from non-exec output

The last line output was being dropped from `sync_spawn_exec` because it
did not end in a newline.