changed output stacktrace format to json

should only write once on completion