I need some help with this program. For some reason, the program is going into an infinite loop. I believe the problem to be in the readAndEdit fxn, but I can't see why it's going into it's infinite loop.

The program is supposed to take input in from an input file line by line into an array. It is supposed to remove consecutive spaces, count the number of words, count the number of sentences. It is then supposed to output the modified text to an output file.

example output of a line: 3: one two three

the number of words in the line is to precede the text.

here's the code:
Code:
// Preprocessor Directives
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

// Global Constants
char PERIOD = '.';
char EXCLAMATION = '!';
char QUESTION = '?';
char BLANK = ' ';

// Function prototypes

// Function name: output_header
// Description: This function outputs the external header
// Precondition: none
// Postcondition: The external header is output
// Usage: output_header();
void output_header();

// Function name: openFiles
// Description: This function opens the input and output files.
// Precondition: one unloaded ifstream variable and one unloaded
//               ofstream variable
// Postcondition: Input file is open and ready for reading; output
//                file is open and ready for writing
// Usage: openFiles(x, y);
void openFiles(ifstream &inFile, ofstream &outFile);

// Function name: readAndEdit
// Description: This function reads the input from the input file
//              and outputs edited input to the output file.
// Precondition: loaded ifstream variable and loaded ofstream
//               variable
// Postcondition: An edited version of the input file is in the
//                output file.
// Usage: readAndEdit(x, y);
void readAndEdit(ifstream &inFile, ofstream &outFile);

// Function name: closeFiles
// Description: This function closes the input file, inlab08.dat
//              and output file, outlab08.dat.
// Precondition: loaded ifstream variable and loaded ofstream
//               variable
// Postcondition: inlab08.dat and outlab08.dat are closed
// Usage: closeFiles(x, y);
void closeFiles(ifstream &inFile, ofstream &outFile);

int main()
{
   // Variable Declarations
   ifstream inFile;
   ofstream outFile;
   
   // Output external header
   output_header();
   
   // Open input and output files
   openFiles(inFile, outFile);
   
   // Edit input to be placed in output file
   readAndEdit(inFile, outFile);
   
   closeFiles(inFile, outFile);
   
   return 0;
}

// Function name: output_header
// Description: This function outputs the external header
// Precondition: none
// Postcondition: The external header is output
// Usage: output_header();
void output_header()
{
   cout << endl;
   cout << "This program reads a paragraph from the input file 'inlab8.dat'";
   cout << endl;
   cout << "and outputs an edited version of the text to the output file";
   cout << endl;
   cout << "'outlab8.dat',  The edited version includes the removal of dual";
   cout << endl;
   cout << "spaces and the number of words per line at the beginning of each";
   cout << endl;
   cout << "line.  The output file also contains the number of sentences in";
   cout << endl << "the file." << endl;
   cout << "*****************************************************************";
   cout << endl;
}

// Function name: openFiles
// Description: This function opens the input and output files.
// Precondition: one unloaded ifstream variable and one unloaded
//               ofstream variable
// Postcondition: Input file is open and ready for reading; output
//                file is open and ready for writing
// Usage: openFiles(x, y);
void openFiles(ifstream &inFile, ofstream &outFile)
{
   inFile.open("inlab8.txt");
   if(!inFile) {
      cerr << "Error in opening file 'inlab8.dat'." << endl;
      exit(1);
   }
   
   outFile.open("outlab8.dat");
   if(!outFile) {
      cerr << "Error in opening file 'outlab8.txt'." << endl;
      exit(1);
   }
}

// Function name: readAndEdit
// Description: This function reads the input from the input file
//              and outputs edited input to the output file.
// Precondition: loaded ifstream variable and loaded ofstream
//               variable
// Postcondition: An edited version of the input file is in the
//                output file.
// Usage: readAndEdit(x, y);
void readAndEdit(ifstream &inFile, ofstream &outFile)
{
   int wordCount = 0, sentenceCount = 0, i = 0, j = 0;
   char lineArray[80], outArray[80];
   char tempChar, lastChar;
   
   inFile.setf(ios::adjustfield | ios::right);
   
   inFile.get(tempChar);
   
   while(tempChar != EOF) {
      i = 0;
      while(i < 70) {
         lineArray[i++] = tempChar;
         inFile.get(tempChar);
      }
      for(j = 0; j < i; j++) {
         outArray[j] = lineArray[j];
         lastChar = lineArray[j];
         if(lastChar == BLANK) {
            wordCount++;
            if(lineArray[j + 1] == lastChar) {
               j++;
            }
         }
         if(lastChar == PERIOD || lastChar == EXCLAMATION || lastChar == QUESTION) {
            sentenceCount++;
         }
      }
      outFile << setw(3) << wordCount + 1 << ": ";
      for(j = 0; j < i; j++) {
         outFile.put(outArray[j]);
      }
      inFile.get(tempChar);
   }
   outFile << sentenceCount + 1;
}

// Function name: closeFiles
// Description: This function closes the input file, inlab08.dat
//              and output file, outlab08.dat.
// Precondition: loaded ifstream variable and loaded ofstream
//               variable
// Postcondition: inlab08.dat and outlab08.dat are closed
// Usage: closeFiles(x, y);
void closeFiles(ifstream &inFile, ofstream &outFile)
{
   inFile.close();
   outFile.close();
}
Also, an example input file is attached.