Fix: start the output buffer before error thrown