Fixes the error where the buffer is printed too early.