inability to read line, more than a specific one!!

Dear

I have a piece of code. It reads input files (Data.txt, Index_list.txt, and Nb_list.txt) and gives output file (NB.txt). Index_list.txt, and Nb_list.txt file have more than 1000 lines. but, it seems the code doesn't read lines after line 102. why does t happen?

Index_list.txt:
```
0 12 0 2 8 2 0 0 11
1 16 0 3 6 7 0 0 21
2 13 1 3 4 4 1 0 12
3 12 1 2 5 4 0 0 13
4 13 0 3 6 4 0 0 12
5 16 0 2 8 6 0 0 21
...
...
...
```

Nb_list.txt:
```
0 12 4520 7046 10446 3126 10901 8877 5200 3550 8134 6806 30 11229
1 16 2602 1228 508 11647 3866 650 8022 13357 7296 267 10787 8153 1680 5591 3124 3107
2 13 7217 10177 10385 2038 3249 10450 4707 13246 6715 12666 12012 8839 3026
3 12 7708 8346 1167 4132 11424 149 189 8487 12445 11637 127 7618
4 13 12911 5350 10473 1155 9048 11317 10600 4000 8721 11082 8681 763 7147
5 16 1724 13256 9531 8765 1313 12710 5417 3679 11640 13374 9880 13231 760 12752 12904 8704
...
...
...
```

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
47
48
49
50
51
  using namespace std;
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>


int main() {
	int ID=0, ID1=0, CN=0, CN1=0, N1=0, N2=0, N3=0, N4=0, N5=0, N6=0, N7=0, N8=0, N9=0, N10=0, N11=0, N12=0;
	int VoronoiIndex_3=0, VoronoiIndex_4=0, VoronoiIndex_5=0, VoronoiIndex_6=0, VoronoiIndex_7=0;
	int V3=0, V4=0, V5=0, V6=0, V7=0, V8=0, type=0, atomsnumber=0;
	double  volume=0;
	string line, line1, line2, namefile;
	
	ifstream Data ("Data.txt");
	if (Data.is_open()){
		for (int linenox = 0; getline (Data,line) && linenox < 6; linenox++){
			if (linenox == 1)  Data>>VoronoiIndex_3>>VoronoiIndex_4>>VoronoiIndex_5>>VoronoiIndex_6>>VoronoiIndex_7;
			if (linenox == 2)  Data>>namefile;
			if (linenox == 2)  Data>>atomsnumber;
		}
		cout<<"VoronoiIndex_3: "<<VoronoiIndex_3<<" VoronoiIndex_4: "<<VoronoiIndex_4<<" VoronoiIndex_5: "<<VoronoiIndex_5<<" VoronoiIndex_6: "<<VoronoiIndex_6<<" VoronoiIndex_7: "<<VoronoiIndex_7<<endl;
		cout<<namefile<<"\n";
		Data.close();
	}
	
	ifstream Index_list_1 ("Index_list.txt");
	ifstream nb_list ("nb_list.txt");
	if (Index_list_1.is_open()){
		
		ofstream NB_1;
		NB_1.open ("NB.txt");
		
		for (int linenox2 = 0; getline (Index_list_1,line1) && linenox2 < atomsnumber; linenox2++){
			Index_list_1>>ID>>CN>>V3>>V4>>V5>>V6>>V7>>V8>>volume;
			if (CN==12 && V5==12 )
			{
				for (int linenox1 = 0; getline (nb_list,line2) && linenox1 < atomsnumber; linenox1++){
					nb_list>>ID1>>CN1>>N1>>N2>>N3>>N4>>N5>>N6>>N7>>N8>>N9>>N10>>N11>>N12;;
					if (ID==ID1){
						cout << ID << " " << ID1<< "\n";
						NB_1 <<ID<<" "<<CN1<<" "<<N1<<" "<<N2<<" "<<N3<<" "<<N4<<" "<<N5<<" "<<N6<<" "<<N7<<" "<<N8<<" "<<N9<<" "<<N10<<" "<<N11<<" "<<N12<<" "<<"\n";
						break;
					}
				}
		   }
		}  
		NB_1.close();
	}
	else cout << "Unable to open file";
}


NB.txt:
```
...
...
...
74 12 6639 9715 6150 6591 12093 2491 1152 7790 9989 12050 2517 5325
84 12 4463 253 12534 1964 11885 1177 5576 636 12343 11979 800 12058
102 12 13429 6795 4441 7871 1749 12657 7760 9501 7860 7025 5163 9085
```
Last edited on
Topic archived. No new replies allowed.