Need to write specific lines of a text into a new text
I have numerical text data lines ranging between 1mb - 150 mb in size, i need to write lines of constant height additions, for example: heights=4 , new text must include lines: 1,5,9,13,17,21.... consequentially.  

i have been trying to find a way to do this for a while now, tried using a list instead of vector which ended up with compilation errors.

I am open to method change as long as it delivers what i need, Thank you for you time and help.

following is what i have so far:
 
    #include <iostream>
    #include <fstream>
    #include <string>
    #include <list>
    #include <vector>

    using namespace std;

    int h,n,m;
    int c=1;

    int main () {

	cout<< "Enter Number Of Heights";
	cin>>h;

    ifstream myfile_in ("sample.txt");
    ofstream myfile_out ("Csample2.txt");
    string line;
    std::string str;
    vector <string> v;
    while (std::getline(myfile_in, line))
        ++n;
    cout<<"Number of lines in text file: "<<n;


    myfile_in >> noskipws;

     if (myfile_in.is_open()) {
     while (!myfile_in.eof()) {

     while (std::getline( myfile_in, line ))
    {
    v.push_back( line );
    int i=1;
    myfile_out<<v[i]; //Not writing to text
    i=i+h;
    }
      }
       }
     else cout << "Unable to open file(s) ";

    cout<< "Reaching end but not writing to file"
    system("PAUSE");
    return 0;
    }

Need to write specific lines of a text into a new text
===

I have numerical text data lines ranging between 1mb - 150 mb in size, i need to write lines of constant height additions, for example: heights=4 , new text must include lines: 1,5,9,13,17,21.... consequentially.  

i have been trying to find a way to do this for a while now, tried using a list instead of vector which ended up with compilation errors.

I am open to method change as long as it delivers what i need, Thank you for you time and help.

following is what i have so far:
 
    #include <iostream>
    #include <fstream>
    #include <string>
    #include <list>
    #include <vector>

    using namespace std;

    int h,n,m;
    int c=1;

    int main () {

	cout<< "Enter Number Of Heights";
	cin>>h;

    ifstream myfile_in ("sample.txt");
    ofstream myfile_out ("Csample2.txt");
    string line;
    std::string str;
    vector <string> v;
    while (std::getline(myfile_in, line))
        ++n;
    cout<<"Number of lines in text file: "<<n;


    myfile_in >> noskipws;

     if (myfile_in.is_open()) {
     while (!myfile_in.eof()) {

     while (std::getline( myfile_in, line ))
    {
    v.push_back( line );
    int i=1;
    myfile_out<<v[i]; //Not writing to text
    i=i+h;
    }
      }
       }
     else cout << "Unable to open file(s) ";

    cout<< "Reaching end but not writing to file"
    system("PAUSE");
    return 0;
    }
