Myfunction only writes w in the new file it creates. The number and spacing of the characters is correct, but it won't write the correct chars and ints.

Any assistance is appreciated.

Code:
void readData(FILE *filename, student grades[], int len ){
   FILE *to= fopen("temp.txt", "w");
   char c;
   int i=0;
   while(fscanf(filename, "%c", &c) != EOF){
      if(c == ',' || c==10 || c==13){
         fprintf(to, " ");
      }
      else
      {
         fprintf(to, "%c", &c);
      }
   }
   fclose(filename);
   fclose(to);

   to= fopen("temp.txt", "r");

   while(fscanf(to, "%s %s %d %d %d", grades[i].last, grades[i].first, &grades[i].hw1, &grades[i].hw2, &grades[i].hw3) >0){
      i++;

   }

}