Very odd behavior of Serial stream

This does not read input 'until there is no more'. It only reads input until the buffer is empty. If there is any gap in the input the buffer may empty before more data arrives.

You could use a timeout:

  unsigned long startTimer = millis();
  while (millis() - startTimer <= 5000) // Allow 5 seconds for input
  {
    if (Serial1.available()) 
    {
      startTimer = millis();  // re-start the timeout
      Serial.write(Serial1.read());
    }
  }

That will accept input until it has been 5 seconds since the last character received.