sam: only skip the last empty match if it follows a newline