How do I fix having an endless loop for my output? : I am trying to read data from a text file and display it on screen. Later I will be attempting to re-order the lines by symbol and percent gain, but first I wanted to make the code simply read and display what is contained.

The actual question I am trying to answer is:

(Stock Market) Write a program to help a local stock trading company automate its systems. The company invests only in the stock market. At the end of each trading day, the company would like to generate and post the listing of its stocks so that investors can see how their holdings performed that day. We assume that the company invests in, say, 10 different stocks. The desired output is to produce two listings, one sorted by stock symbol and another sorted by percent gain from highest to lowest. The input data is provided in a file in the following format: symbol openingPrice closingPrice todayHigh todayLow prevClose volume For example, the sample data is:
Develop this programming exercise in two steps. In the first step (part a), design and implement a stock object. In the second step (part b), design and implement an object to maintain a list of stocks. 
a. (Stock Object) Design and implement the stock object. Call the class that captures the various characteristics of a stock object stockType. The main components of a stock are the stock symbol, stock price, and number of shares. Moreover, we need to output the opening price, closing price, high price, low price, previous price, and the percent gain/loss for the day. These are also all the characteristics of a stock. Therefore, the stock object should store all this information. Perform the following operations on each stock object: i. Set the stock information. ii. Print the stock information. iii. Show the different prices. iv. Calculate and print the percent gain/loss. v. Show the number of shares. a.1. The natural ordering of the stock list is by stock symbol. Overload the relational operators to compare two stock objects by their symbols. a.2. Overload the insertion operator, <<, for easy output. a.3. Because the data is stored in a file, overload the stream extraction operator, >>, for easy input. For example, suppose infile is an ifstream object and the input file was opened using the object infile. Further suppose that myStock is a stock object. Then, the statement: infile >> myStock; reads the data from the input file and stores it in the object myStock.
b. Now that you have designed and implemented the class stockType to implement a stock object in a program, it is time to create a list of stock objects. Let us call the class to implement a list of stock objects stockListType. The class stockListType must be derived from the class listType, which you designed and implemented in the previous exercise. However, the class stockListType is a very specific class, designed to create a list of stock objects. Therefore, the class stockListType is no longer a template. Add and/or overwrite the operations of the class listType to implement the necessary operations on a stock list. The following statement derives the class stockListType from the class listType. class stockListType: public listType { member list }; The member variables to hold the list elements, the length of the list, and the max listSize were declared as protected in the class listType. Therefore, these members can be directly accessed in the class stockListType. Because the company also requires you to produce the list ordered by the percent gain/loss, you need to sort the stock list by this component. However, you are not to physically sort the list by the component percent gain/loss. Instead, you will provide a logical ordering with respect to this component. To do so, add a member variable, an array, to hold the indices of the stock list ordered by the component percent gain/loss. Call this array sortIndicesGainLoss. When printing the list ordered by the component percent gain/loss, use the array sortIndicesGainLoss to print the list. The elements of the array sortIndicesGainLoss will tell which component of the stock list to print next. 
c. Write a program that uses these two classes to automate the company’s analysis of stock data.


This may be my end goal but I am not attempting to do some of what it describes yet.



The part I believe is causing the issue is somewhere in here:

    void printScreen(ifstream &infile)
    {
    	stockType in;
    	stockType out;
    	int count = 0;
    	string line;
    
    	cout << "********* First Investor's Heaven *********" << endl;
    	cout << "*********    Financial Report     *********" << endl;
    	cout << "Stock       Today           Previous Percent" << endl;
    	cout << "Symbol   Open  Close   High   Low   Close  Gain   Volume" << endl;
    	cout << "----- ----- -----  ----- ------ -------  -----" << endl;
    
    	while (getline(infile, line))
    	{
    		count++;
    	}
    
    	for (int i = 0; i < count; i++)
    	{
    		infile >> in;
    		cout << out;
    	}
    
    	cout << "-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*";
    }

My main function is:

    int main()
    {
    	char repeat = ' ';
    	string userSelection;
    
    	int selection;
    
    
    	ifstream infile;
    
    	cout << "Please enter a filename of type .txt: ";
    	cin >> userSelection;
    
    	infile.open(userSelection);
    
    	if (!infile)
    	{
    		cout << userSelection << " is not found. The program will now exect. Please ensure the filename is correct and the file is in the porper directory." << endl;
    		exit(0);
    	}
    
    	do
    	{
    		selection = Menu();
    
    		switch (selection)
    		{
    		case 1:
    			printScreen(infile);
    			break;
    		case 2:
    			exit(0);
    			break;
    		default:
    			cout << "An error has occured, the program will now exit." << endl;
    			exit(0);
    		}
    		cout << "If you would like to enter another file enter y. Otherwise the system will conclude: ";
    		cin >> repeat;
    	} while (repeat = 'y');
    
    	infile.close();
    	return 0;
    }

and I am attempting to utilize this:

    ostream& operator << (ostream& out, stockType& temp)
    {
    	char tab = '\t';
    
    	out.imbue(locale(""));
    	out << setprecision(2) << fixed;
    
    	out << temp.getStockSymbol() << tab << setw(6) << temp.getOpeningPrice() << tab << setw(6) << temp.getClosingPrice() << tab << setw(7) << temp.getHighPrice() << tab << setw(8) << temp.getLowPrice() << setw(9) << temp.getPreviousPrice() << setw(10) << temp.getPercentGainLoss() << "%" << tab << setw(11) << temp.getStockShares() << endl;
    
    	return out;
    }
    
    istream& operator>>(istream& in, stockType& obj)
    {
    	string temp;
    	double val;
    	int x;
    
    	in >> temp;
    	obj.setStockSymbol(temp);
    
    	in >> val;
    	obj.setOpeningPrice(val);
    
    	in >> val;
    	obj.setClosingPrice(val);
    
    	in >> val;
    	obj.setHighPrice(val);
    
    	in >> val;
    	obj.setLowPrice(val);
    
    	in >> val;
    	obj.setPreviousPrice(val);
    
    	in >> x;
    	obj.setStockShares(x);
    
    	return in;
    }

My output should be ordered the same way as it is being read yet I am getting no output of the symbol and I am getting an endless loop that doesn't seem to be reading everything.


