Updated to condense output to one line, turn newlines in command output into spaces with the exception of the last character.

Updated to condense output to one line, turn newlines in command output into spaces with the exception of the last character. Tests updated to reflect the new expected output. Had to mess with the sed strings a little to get backslashes and double quotes escaped properly after condensing to a newline.