Pro Micro/ RC522 RFID reader only works when the port is listening.

Hello everyone,

i have seem to be stuck in a very strange situation. I have an Pro Micro and a RFID reader which i am trying to work together. The sketch works since i have uploaded it to a MEGA 2560 and a UNO R3 and it works like it should. It also works with the Pro Micro but only when the port is listening. As soon as i close the port, it stops working. Would someone please shed some light on what might be my issue. I'm new to this and your help is greatly appreciated. Thank you.

/*
#include <SPI.h>
#include <MFRC522.h>


#define RST_PIN         10         // Configurable, see typical pin layout above
#define SS_PIN          2          // Configurable, see typical pin layout above

MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.

String read_rfid;
String ok_rfid_1 = "xxxxxxxx";
String ok_rfid_2 = "xxxxxxxx";
int access = 0;
int did = 0;
int lockSig = 3; //signal from arduino.
int unlockSig = 4; //signal to arduino.
int RXLED = 17;

void setup() {
  pinMode(RXLED, OUTPUT);
  pinMode(unlockSig, OUTPUT);
  digitalWrite(unlockSig, LOW);
  pinMode(lockSig, INPUT);
  Serial.begin(9600);         // Initialize serial communications with the PC
  SPI.begin();                // Init SPI bus
  mfrc522.PCD_Init();         // Init MFRC522 card
}
void dump_byte_array(byte *buffer, byte bufferSize) {
  read_rfid = "";
  for (byte i = 0; i < bufferSize; i++) {
    read_rfid = read_rfid + String(buffer[i], HEX);
  }
}
void allow_access() {
  access = 1;
  did = 1;
  }
void deny_access(){
  access = 0;
  did = 0;
}

void loop() {

  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent())
    return;

  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial())
    return;

  dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
 
  if (read_rfid == ok_rfid_1) {
    Serial.println(read_rfid);
    Serial.print("What's up?");
    allow_access();
  }
  if (read_rfid == ok_rfid_2) {
    Serial.println(read_rfid);
    Serial.print("What's up?");
    allow_access();
  }
  mfrc522.PICC_HaltA();
  
// else not needed. Anything else is not ok, and will not open the door...
  //------------------------------Signal to Arduino loop--------------------------------------
  if (access == 1 && did == 1) { //Card was read.
    digitalWrite(unlockSig, HIGH);
    delay(50);
    digitalWrite(unlockSig, LOW);
    digitalWrite(RXLED, HIGH);    // set the LED off
    did = 2;
    }
  if (digitalRead(lockSig) == HIGH && did == 2) {
    digitalWrite(RXLED, LOW);    // set the LED off
    deny_access();
  }
}