It looks like this statement can be removed because the buffer is entirely written in the loop below.