Currently, this is the code that I have created but I can't seem to find the problem behind it. I am writing a program that encrypts
int countWords(FILE *f){
   int count = 0;
   char ch;
   while ((ch = fgetc(f)) != EOF){
       if (ch == '\n')
           count++;
   }
   return count;
}
int main ( int argc, char *argv[] ){
    //int min > 0; 
    //int max >= int min; 
    time_t current_time;
    char* c_time_string;
    current_time = time(NULL);
    /* Convert to local time format. */
    c_time_string = ctime(¤t_time);
    printf("Program started %s\n", c_time_string);
    if ( argc != 2 ){ 
        printf( "usage: %s filename\n", argv[0] );
    }else {
        int wordCount = 0;
        FILE *file = fopen( argv[1], "r" );
        //wordCount += countWords(file);
        //printf("Total number words processed => %d\n", wordCount);
    if ( file == 0 ){
        printf( "Could not open file.\nProgram halted. Please verify the file path and try again.\n" );
    }else {
            int x;
            while  ( ( x = fgetc( file ) ) != EOF ){
                printf("%c", x );
            }
            fclose( file );
        }
                /// CRYPT ///
         char * plaintext = argv[1] ;
         char * hash_type_1 = "$1$";  // type 1 implies md5 (number of iteration is only 1000 rounds)
         char * hash_type_2 = "$6$";  // type 2 implies sha-512 (default value as in yr 2017, number of iteration is minimum 10,000 rounds )
         char * salt_1 ="$";           // a simplified 0 length salt.
         char * salt_2 ="ABCD1234$";   // a normal 8 character salt.
         char * result;
         char encyption_scheme[20]; // 20 is more than enough.
         // prepare the first call using md5 and empty salt
         strcpy(encyption_scheme,hash_type_1);
         strcat(encyption_scheme,salt_1);
         result = crypt(plaintext,encyption_scheme);
         printf("MD5: %s\n",result);
         // prepare the second call using sha-512 and a 8-char salt
         strcpy(encyption_scheme,hash_type_2);
         strcat(encyption_scheme,salt_2);
         result = crypt(plaintext,encyption_scheme);
         printf("Sha512: %s\n",result);
         printf("Program ended %s\n", c_time_string);
        //transfer the output to mytab2411.txt//
        result = freopen("mytab2411.txt", "w+", stdout);
    }
            return 0; 
}
I need some help with my coding. I am trying to code a program which is able to transfer the output of my program to an empty file. Please help me find my errors.
 
     
    