Fix garbage output on error