Implement `writeBuffer(const char *str)` and apply