Key difference is the lack of that delay(1000). That's most likely the problem as I said already: characters getting lost as they don't fit in the buffer due to you reading it very infrequently.
Now where you write the received character to the console, that's the place where you should store it into your string. And no delay() call needed. Use some kind of end tag, a special character or so, maybe simply a \n or \r. There's got to be something for you to identify a message is complete.
char buffer[51]; // As small as possible, but big enough to hold a complete message plus null terminator
byte counter = 0;
void loop() {
if (Serial2.available()) {
char c = Serial2.read();
buffer[counter] = c;
if (c == yourEndTag) {
// string complete
buffer[counter + 1] = '\0'; // null terminate the string.
stringComplete = true;
}
counter++;
if (counter == 50) {
// Buffer full!
}
}
if (stringComplete) {
// Deal with it!
// When string is processed get ready for a new message:
stringComplete = false;
counter = 0;
}
}
And do note that I used string (c-string, char array) rather than String.