           else if record.json.stderr? and record.json.stderr.length
             stderr = record.json.stderr
             record.json.stderr = "v-V-v  See below. v-V-v"
-          json = inspect(record.json, false, 1000).replace(/^(\s*\S.*)$/mg, "  $1")
+          json = inspect(record.json, false, 1000).replace(/^([^\S\n]*\S.*)$/mg, "  $1")
           process.stdout.write "#{json}\n"
 
         if record.exceptions
           writeExceptions(record.exceptions, "Uncaught exception")
         else if stderr
           process.stdout.write "\n  #{makeDashes("Output from stderr")}\n"
-          process.stdout.write stderr.replace(/^(\s*\S.*)$/mg, "  $1")
+          process.stdout.write stderr.replace(/^([^\S\n]*\S.*)$/mg, "  $1")
 
 fs.open "/var/log/messages", "r", (error, fd) ->
   throw error if error

    ).apply(exception.location)
  
  # Print the actual message, indented.
  process.stdout.write "#{exception.message.replace(/^(\s*\S.*)$/mg, "  $1")}\n"

  # Print JSON if any exists. If there is stderr output, replace it with a message
  # to look for the output below.

    writeExceptions(exceptions, "Nested exception")
  else if stderr
    process.stdout.write "\n  #{makeDashes("Output from stderr")}\n"
    process.stdout.write stderr.replace(/^([^\S\n]*\S.*)$/mg, "  $1")

# In case you forget, you put this in its own method to get an empty namespace.
sendOutput = (output) ->
