This buffer size is wasteful, but it works.