Recording RFID CARD data on SD CARD

Hello everybody,

I want to record RFID card numbers on SD Card. but I couldn't do it. I am using Arduino Uno, Catalex SD Card Module, RDM 6300 RFID Card Reader.

Here the codes I wrote. No matter RFID Card read, it is displaying only -1. Please correct my codes.

#include <SoftwareSerial.h>
#include <SPI.h>
#include <SD.h>
#include <EEPROM.h>

SoftwareSerial RFID(0,1); // RX and TX
int i;

File myFile;

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

if (RFID.available() > 0) 
{
i = RFID.read();
Serial.print(i, DEC);
Serial.print(" ");
}
pinMode(SS, OUTPUT);
while (!Serial) {
   ;                                
 }
if (!SD.begin(4)) {               
   Serial.println("SD initialization failed!");
   return;
}
myFile = SD.open("test.txt", FILE_WRITE);
 if (myFile) {
   Serial.print("Writing to testfile.txt...");
   myFile.println(RFID.read());  
   myFile.close();
   Serial.println("done.");
 } else 
{
   Serial.println("error opening test.txt");
 }
myFile = SD.open("test.txt");
 if (myFile) {
   Serial.println("test.txt:");
   while (myFile.available()) {
     Serial.write(myFile.read());
   }
   myFile.close();
 } else {
   Serial.println("error opening test.txt");  
 } 
}
void loop()
{
myFile = SD.open("test.txt", FILE_WRITE);

if (myFile) {
Serial.print("Data is recording to test.txt ...");
int chk = RFID.read();
myFile.print(" User ID: ");
myFile.println(RFID.read());
myFile.close();
   Serial.println("Recorded.");
} else {
   Serial.println("File couldn't open.");
 }
delay(1000);
 }

(Code tags added by moderator, extra blank lines removed)

Here is one possible issue:

SoftwareSerial RFID(0,1); // RX and TX

This is a bad choice for software serial on a Uno because these are the hardware serial ports and these will interfere with each other.

If you still have problems, break the code in two parts and test each separately ( RFID handling and SD card code).

6v6gt:
Here is one possible issue:

SoftwareSerial RFID(0,1); // RX and TX

This is a bad choice for software serial on a Uno because these are the hardware serial ports and these will interfere with each other.

If you still have problems, break the code in two parts and test each separately ( RFID handling and SD card code).

I have changed them with

SoftwareSerial RFID(2,3); // RX and TX and still didn't work. Do you have any idea?

This line
pinMode(SS, OUTPUT);
probably needs to go earlier in setup() and then written HIGH so SS is disabled until it is called LOW to access the SD card.