I had problems using PaulS's while loop method at 9600 baud. Sometimes, it would only display 1 or 2 characters on each line. I think it is due to the reading rate not fast enough
At 9600 bits per second, it takes over 1 millisecond to transmit and receive a character.
In that time, the processor could execute up to 16 000 instructions, so to say "the reading rate is not fast enough" doesn't seem very likely, does it?
I don't think you've understood how PaulS's code works, and your code will not work with an ordinary terminal emulator and a hesitant typist.
Your code also contains an unnecessary initialisation loop
void loop()
{
size_t len = Serial.readBytes(buf, 50);
buf [len] = '\0';
Serial.println(buf);
}