List only *.csv files

okay I think I have figured out something but not too sure as I am running a w5100 card with the SD I have disabled the network part on start up

well I know now it is only an issue with creating it stop at

error: Write failed

should I change the line to something else?

#include <SdFat.h>
#include <SdFile.h>

// SD chip select pin
const uint8_t chipSelect = SS;

// file system object
SdFat sd;
SdFile file;
SdFile	plFile;		// Playlist file
	SdFile	lFile;		//list files
      	uint16_t count;		// count of files
        int  FNAME_SIZE;
        char  fname[12];
        char  file_list[] = "FILELIST.TXT";
        char *CSV_EXT = "CSV"; 
#define SD_SELECT 4

// define a serial output stream
ArduinoOutStream cout(Serial);
//------------------------------------------------------------------------------
void setup() {
  Serial.begin(9600);
           
      pinMode(10,OUTPUT);
  digitalWrite(10,HIGH);
 
 
if (!sd.begin(chipSelect, SPI_HALF_SPEED)) sd.initErrorHalt();
Serial.println("program started");
if (plFile.open(file_list, O_CREAT|O_WRITE)){
    sd.errorHalt("Write failed");
  }
 
 count = 0;
 while (file.openNext(sd.vwd(), O_READ))
	{
  Serial.println("Started");
    	if (file.isFile())
		{ file.getFilename(fname);
		if (strcmp(CSV_EXT, &fname[strlen(fname)-strlen(CSV_EXT)]) == 0){
                Serial.print(fname);			
  	       plFile.write(fname, 12);
				count++;
			}
		}
		file.close();
	
}
plFile.close();
Serial.println("count");
Serial.print(count); 
}

void loop() {}