Circular stdio buffer

This allows us to do partial sends which makes things a bit more robust
against buffer overruns.

Also silence a compiler warning in `printf`.