Hello,

I am trying to coerce my program into reading one line of data from a data file. It isn't working very well. What it does do rather well is asks the user what terminal number they want information on, then takes that number and checks to see if it is greater than 1 (the computer terminals in the data file are numbered 1 thru 5 sequentially), if it is greater than 1, it multiplies it by 30 (there are 30 characters on each line) to move the read position to the correct line. I can verify that seekg() is getting the correct number by displaying the value in the scope where seekg() resides. But after that the program seems to be stuck in a loop of sorts and I am not having success determining A) what is causing this unwanted un-ending loop, and B) why I am not getting any output of data that is being read from the file.
Here is the program:
Code:
#include <iostream>    // cout, cin, <<, >>
#include <string>      // string
#include <cassert>     // assert
#include <fstream>     // ifstream
using namespace std;

char c;
string line;
int termNumb;
int lineNumber;


int main()
{	
	ifstream inFile("data.txt");      // open the file
	assert(inFile.is_open() );        // check for success.
 
	cout << "Enter the terminal number (such as 001, 002...): ";	
	cin >> termNumb;             // get the line number of the data field

	// 
	int lineNumber = 0;
	if (termNumb > 001) 
	{
		  lineNumber = 30 * termNumb;
		  cout << "The read position is at: " << lineNumber << "\n";
	}
	else lineNumber = 0;
	
	for (;;)
	{
		inFile >> line;
		if(inFile.eof()) break;
		inFile.seekg(lineNumber, ios::beg);
		getline(inFile, line);          
		
	 }
	cout << "Information: " << line << "\n";	
    cout << "The read position is at: " << lineNumber << "\n";
inFile.close();
}
And this is the data file I am using:
Code:
001 A53 45-08 1200 A 03-26-04
002 B15 41-07 2400 B 03-26-04
003 C71 48-01 4800 C 02-13-03
004 D22 21-01 4800 D 01-14-01
005 E35 17-05 9600 E 12-01-03
I'd appreciate any help I can get. Thanks.