Use this to write a string, whether in mock mode or with real stdout.
void write(String str) { if (mock) { _buffer += str; _flush(); } else { stdout.write(str); } }