func: another fix for WriteBufferIfNecessary