XBee communiation error. Very simple.

I’m working on a project about wireless communication using XBee(S2C).

First of all, It’s my sketch making an error.

void setup() {
    Serial.begin(9600);
    Serial.println("1");
}

void loop() {
    if(Serial.available()){        
        String answer = Serial.readStringUntil('\n');
        answer.trim();

        int i_answer = answer.toInt();
        String data = String(i_answer + 1);

        Serial.println(data);
                
        delay(1000);
    }    
}

As you can see, it’s totally simple.

It’s no problem when the number of communicating Xbees is only two,

however the problem occurs when the number of Xbee is more than three.

It works fine at first, but it stops its ‘+1’ function and just repeats the same value at some point(to be exact, at the point that I turned on third Xbee).

Here’s my recording(gif) of the error:

What would be a problem? Please give me some help…

int i_answer = answer.toInt();If the String does not hold a numeric value (only) .toInt() returns 0.
This is what must be happening.

Great help. Thanks!