title: how to copy and write a file from a specific line number
body: <p>I would like to copy a huge txt file and 'shrink' it. this is my code, but it seems it's still takes a lot of time reading the file. is there a way to read from a specific line number to EOF? for instance, the first 1 million lines are not useful to me, how to read from line 1 million. or anyway to read from EOF?          </p>
  
  <pre><code>include&lt;stdio.h&gt; 
  include&lt;stdlib.h&gt;
  void main() {
     FILE *fp1, *fp2;
     char ch;
     int i = 1;
     int n = 0;
     int k;
  
     fp1 = fopen("co.data", "r"); /*  open a file to read*/
     fp2 = fopen("Output.txt", "w");          /*  open a file to write*/
     printf("please enter how many lines do not need to be copied\n");
     scanf ("%d", &amp;k); 
     while (1) {
        ch = fgetc(fp1);                        /*  a loop to read/copy    the file*/
        if (ch == '\n')                            /*  record the number of lines*/
        i++;   
        if (ch == EOF)
           break;
  
        else if (i&gt;k)                       
  
           putc(ch, fp2);
  
     }
  
     printf("File copied Successfully!\n");
     printf("number of lines read is %d\n",i-1);
     printf("number of lines copied is %d\n",i-1-k);
     fclose(fp1);
     fclose(fp2);
  } 
  </code></pre>