My code is not working as expected. When I run the program and try to output n ( on line ABC ) , the program displays only "New" on the screen. why isn't the program reading the rest of the file? Any help will be appreciated. Thanks
#include <iostream>
#include <fstream>
using namespace std;
class stateData{
private:
    string name, capital;
    int area, admissionYear, admissonOrder;
public:
friend ifstream& operator>>(ifstream& input, stateData &state);
friend ostream& operator<<(ofstream& output, stateData &state);
};
ifstream& operator >>(ifstream &input, stateData &state){
    string name, capital,n;
    int area, admissionYear, admissionOrder;
    input >> n;
    input>>capital;
    input>>area;
    input>>admissionYear;
    input>>admissionOrder;
    state.name=n;
    cout << n;  // LINE ABC
}
int main(){
    stateData states[50];
    string n;
    ifstream infile;
    ofstream outfile;
    int hashTable[101];
    infile.open("Ch9_Ex8_data.txt");
    if (infile.fail()){
        cout << "Sorry, file could not be opened. ";
        exit(0);
    }
    for (int i=0; i<50; i++){
        infile>> states[i];
    }
}
}
Given below is the contents of the file: "
New Hampshire 
Concord
9304 1788 9
Massachusetts
Boston
8257 1788 6
...
