Unless there is something strange going on, the only way the small parts of the string can be printed is if sometimes when the buffer is being chcked in the while loop, the buffer appears empty.
Of course that's why the while loop terminates.
The while statement says "continue doing this IF the conditional part is true". My question remains. If the while statement sees that there is data, the delay statement can only result in an increase in the amount of data, not a decrease, since the only way to decrease the amount of data is to read it or flush it, neither of which the delay statement does. So, why is the if statement necessary?
The delay() masks the fact that there is no checking to see that a complete packet has arrived, because, coincidentally, if you wait long enough, the whole packet arrives, and you can pretend that all the data that did arrive constitutes a packet and nothing but a packet.