fix debug output for stderr/stdout