Why the program is not looping?

I write this program to open a text file(example.txt) in a csv(output) file with a variable interval which is another text file (Length.txt). the program was suppose to go through all the lines of the example.txt file but it is stopping after first line. can anyone help me to solve this problem? Please help me.
i write the following program:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main () {
  string line, line1, word;
  ifstream myfile1 ("example.txt");
  ifstream myfile3 ("length.txt");   
  ofstream myfile2 ("output.csv");
  int intReturn=0;
  if (myfile1.is_open()&& myfile3.is_open())
  {
      int i=0;
   while (!myfile1.eof())
         {
         getline (myfile1,line);
         
         while (!myfile3.eof())         
            {
            getline (myfile3,line1);
            cout << line1 << endl;         
            intReturn = atoi(line1.c_str());
            word=line.substr(i,intReturn);
            cout << i << endl;
            i=i+intReturn;
            cout << word << endl;
            if (myfile2.is_open())
               {
               myfile2<< word;
               myfile2 << "\n";
               
               }
            }

         }      
         myfile1.close();
         myfile2.close();
         myfile3.close();
  }

  else cout << "Unable to open input file";

  return 0;
}
Last edited on
Topic archived. No new replies allowed.