The program I am trying to write has to stop reading data from a file at 50 names or at EOF, whichever comes first. The test data file that I'm using has 2 pieces of data in it so it should stop at EOF. The problem is, is that is it is creating 50 entries in the output files that contain blank data. Please help. Here is the code that contains the lines for the loop. Thanks.
cout << "Please enter the name of the input file.";
gets(input);
infile.open(input);
if(infile)
{
cout << "Please enter the name of the output file.";
gets(output);
outfile.open(output);
if(outfile)
{
outfile << "Program 2 The people class:" << '\n' << '\n';
while(i<50 || !EOF)
{
getline(infile,name);
outfile << "The name is: " << name << '\n';
do
{
infile >> num;
if (num>0 && num<100)
{
num2 = num2+num;
j++;