Using string byte length to compute how much buffer must be increased.

I'm not 100% sure but I highly suspect that the call to increaseBufferIfNecessary should be like this.