Fix result whitespace output

Previously, an extraneous newline appeared before the result line, even if no output preceded it. Also, the result did not end with a new line so the shell prompt got indented.