I have started working on a program, and for the life of me I can't find a bug which continuously searches the eof and doesn't end. It is most certainly a problem with my fileread and widthcount functions, and they most likely have the same error. Is there a fix for this? It just keeps looping.
The file input is this
12.43 62.38 Los Angeles
21 59 Columbus, Ohio
0 15.58 Green Bay, Wisconsin
This continues for another 10 lines.
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>
using namespace std;
void fileread(ifstream &ifFile, char newline, double &temp1, double &temp2, string city);
void widthcount(ifstream &ifFile, int &maxCount, char newline);
int main() {
   double temp1, temp2, minTemp, maxTemp;
   int maxCount;
   char newline=' ';
   string FileRead, city;
   ifstream ifFile;
   cout << "Please enter the location of the input file: ";
   cin >> FileRead;
   ifFile.open(FileRead.c_str());
   if (ifFile.fail()) {
       perror(FileRead.c_str());
       exit(1);
   }
   widthcount(ifFile, maxCount, newline);
   while(!ifFile.eof()) {
       widthcount(ifFile, maxCount, newline);
   }      
   ifFile.close();
   ifFile.open(FileRead.c_str());
   fileread(ifFile, newline, temp1, temp2, city);
   while(!ifFile.eof()) {
       fileread(ifFile, newline, temp1, temp2, city);
       cout << left << setw(20) << city
             << right << setw(6) << fixed << setprecision(2) << temp1
             << right << setw(6) << fixed << setprecision(2) << temp2 << endl;
   }
}
void fileread(ifstream &ifFile, char newline, double &temp1, double &temp2, string city) {
   int charcount = 0;
   ifFile >> temp1 >> temp2;
   while (newline == ' ')
       ifFile.get(newline);
   while (newline != '\n' || !ifFile.eof()) {
       charcount++;
       ifFile.get(newline);
   }
}
void widthcount (ifstream &ifFile, int &maxCount, char newline) {
   double temp1, temp2;
   int charcount = 0;
   ifFile >> temp1 >> temp2;
   ifFile.get(newline);
   while (newline != '\n' && !ifFile.eof()) {
       charcount++;
       ifFile.get(newline);
       cout << newline;
   }
   if (charcount > maxCount)
    maxCount = charcount;
}
 
     
     
    