Program won't read past the first entry in file

I need help fixing this C++ program that is not writing the second entry in one file to another file. It only seems to be writing the first entry only to the file and then after that the while loop is terminating, even though the end of the file has not been reached. Here is the 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
   indata.open("income.dat", ios::out | ios::binary);
   
   while (true)
   {
   	indata.ignore();
   	indata.getline(person[count2].name, NAMESIZE); 
   	indata >> person[count2].income;
   	indata >> person[count2].rent;
   	indata >> person[count2].food;
   	indata >> person[count2].utilities;
   	indata >> person[count2].miscell;
	
	if (count2 == 0)
	{	
   	
   		outdata << setw(20) << "Name" << setw(10) << "Income" << setw(10) << "Rent" 
	   		<< setw(10) << "Food" << setw(15) << "Utilities" << setw(15)
           		<< "Miscellaneous" << setw(10) << "Net Money" << endl << endl;
	}

   	outdata << setw(20) << person[count2].name 
                << setw(10) << person[count2].income 
                << setw(10) << person[count2].rent 
                << setw(10) << person[count2].food 
                << setw(15) << person[count2].utilities 
                << setw(15) << person[count2].miscell 
                << setw(10) << person[count2].net << endl;

	count2++;
   }

   outdata.close();

}


Conditions I have tested in the while loop include, indata, !indata.eof(), and indata.good().
Any thoughts? Thanks
Last edited on
Bump:)
Formatted input extraction and binary mode don't mix well.
Topic archived. No new replies allowed.