Hi,

I modified my above program with the following code to read each value of column 1 of my input file (*.ref) and create multiple Output files (*.brt) with name as the value at the column 1 of the input file. For each change in the value at column 1 of input file, a new output file (*.brt) should be created. But it doesn't seem to work. Could you please help me with the changes to the following code so that it works. I already seem to have messed up on this Trivial change :-

Code:
// Take the output file names (*.brt) from column 1 of the data of the input file (*.ref). 
// New output file created for each change in the value of the first column of the 
// input file.       
 
                f_name[12] = fgetc(ref_file);
                f_name[13] = fgetc(ref_file);
                f_name[14] = '.';
                f_name[15] = 'r';
                f_name[16] = 'e';
                f_name[17] = 'f';
                f_name[18] = 0;
                fgetc(ref_file);
                while(!feof(ref_file))
 
    {
            ch = fgetc(ref_file);
               // brt_file = fopen(f_name, "a");
                  commaCount = 0;
    }
   while(ch != newline && commaCount < 4) 
         {
              if (ch == ',')
    {
                 commaCount ++;
    }
              else
     {
                  //fputc(ch,brt_file);
                  ch = fgetc(ref_file);
     } 
         }
 
          //fputc(' ',brt_file);
       //flush rest of line
         while(ch != newline )
   {
            ch = fgetc(ref_file);
   }
         //fclose(brt_file); 
 
       //f_name[12]=fgetc(brt_file);
       //f_name[13]=fgetc(brt_file);
       //f_name[14]= '.';
       //f_name[15]='b';
       //f_name[12]='r';
       //f_name[12]='t';
       //f_name[12]=0;
       //fgetc(brt_file);
    //}
 
    //return 0 ;

Thanks a lot.
Marconi.