Problems while Logging Data through nrf module into a Micro SD module

Im a beginner to SPI communication and have just started working with arduinos. please help me out

Basically, I'm trying to send some data through a transmitter nrf module and receive the data at another nrf module and simultaneously store the data in the sd card.

My transmitter code

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

int c;
int x=-1;
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00011";


void setup() {
  
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}
  
 
void loop() { 
  
  c=0;
  long curtime;
    
  radio.write(&x, sizeof(x));
  Serial.print("actual");
 
  Serial.println(x);     
  delay(100);  
 
  for(c=0;c<=99;c++){
  
    radio.write(&c, sizeof(c));   
    Serial.println(c);
    delay(500);
  }
}

I'm sending 1 to 100 values along with a starting value which will make sure the receiver only receives data starting from 1.

Next, I'm trying to receive this data through another nrf module and store those variables in an SD card module connected to the same Arduino as the receiver through SPI ie giving same SCK, MISO and MOSI while keeping CS different.

this is the receiver code

#include <SPI.h>
#include "RF24.h"
#include <SD.h>


RF24 radio(7,8);


const byte address[6] = "00011";
unsigned long counter = 1;


const int cs_SD = 9;
const int cs_RF = 8;

int b;
int a;

File maFile;

void setup() {
 
  
  Serial.begin(9600);

  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
  p:
  if (radio.available()){
    k:
    radio.read(&b,sizeof(b));
 
    if(b==-2){
      Serial.println("working");
     }
    else{
      goto k;}
  }
  else{
   goto p;}
  
  SD.begin(cs_SD);

}

void loop() {
  int del = 100;
  delay(del);

  char h[30];
   
  if (radio.available()){  
    radio.read(&a,sizeof(a));
    Serial.println(a);  }

  maFile = SD.open("test1.txt", FILE_WRITE);

  if (maFile) {
    Serial.print("Writing to test1.txt...");
    maFile.println(a);

    maFile.close();
    Serial.println("done.");
  } else {
      Serial.println("error opening test.txt");
  }
 
}

the output of the receiver arduino is showing "working" even if I haven't sent any data through the transmitter and then it proceeds to error opening test.txt .