I think before 'mashing' together anything you need to go over the concepts of basic C.
It would be good practice to use {} when starting and ending if's and loops.

Start the main function like so:

Code:
int main (void) {


  return 0;
}
Loops

Code:
while (i != 10) {

  DO SOMETHING

  i++;
}

Opening files

Code:
FILE *fo;

fo = fopen("filename.$", "#"); //# can be a, r or w, or some others, research !!!
                                               //$ can be only basic text files like rtf or txt
Copy from one file, writing to another

Code:
FILE  *fo;
FILE  *fw;
char c;

fo = fopen("C:\\Directory\\Directory\\Directory\\Filename.txt","r");
fw = fopen("C:\\Directory\\Directory\\Directory\\Output.txt", "w"); 

while(1){
      
      c = fgetc(fo);
      
      if(c == EOF){
        break;
      }
      else{
       PERFORM ACTIONS ON CHARACTERS HERE
        fputc(c,fw);
      }
}
Hope some of that helps