Add flow control. Fix #10.

Invoke drain() after each write.