Perhaps serial receive buffer is not being empty in Arduino Mega 2560

The problem is whenever I receive the data from UHF card whose last three bytes are 0XDF, 0x34 and 0xBF, the serial monitor keeps on receiving the same data even when the TX and RX pins are removed

#include <SoftwareSerial.h>
SoftwareSerial mySerialU (10,11);  // 10 RX,  11 TX  (for UHF)

unsigned char BB1;
unsigned char BB[5];
unsigned int i=0;

void loop ()
{
  Serial.flush();
  while(mySerialU.available () > 0)
  { 
      BB1 = mySerialU.read ();
      
      if (BB1 == 0 )
      {
        Serial.println();
        i=0;   
        break;       
      }

      BB[i] = BB1;         
      Serial.print(BB[i],HEX);   
      i++;    
      
      if(BB[2]==0xDF && BB[3]==0x34 && BB[4]==0xBF) 
      {      
        delay(500);
        digitalWrite(LED_BUILTIN, HIGH); 
        Serial.println("Detected BF");
      }
  }
}

With 4 hardware serial ports on the Mega, why are you using SoftwareSerial?

the serial monitor keeps on receiving the same data even when the TX and RX pins are removed

You didn't think it important to show what the Arduino sends to the serial port? I do.

OK, let me try with the hardware serial. I will get back soon.

Thanks for your reply.