need help troubleshooting... i want this to copy from the preList into the readyList whenever the requirements are met... when x%1000 = 0 and whenever preList[i][0] = x.... why won't this code work??

Code:
#include <iostream>
#include <cstdlib>
#include <fstream>


using namespace std;



long int preList[21][2];
long int readyList[21][2];




int main()
{

	fstream inFile;
	inFile.open("times.txt", ios::in);


	int arrivalTime;
	float timeToProcess;
	int i, z = 0;
	long int x = 0;
	int p;


	//make sure file opens

	if (!inFile)
	{
		cout<<"Error opening file."<<endl;
		exit(1);
	}

		
	//open file, get stuff in there
	
	while(!inFile.eof())
	{	

		
		for(i=0; i<=21; i++)
		{	
			
			inFile>>arrivalTime>>timeToProcess;

			preList[i][0] = arrivalTime * 1000;
			preList[i][1] = timeToProcess;

		    cout<<preList[i][0]<<"  "<<preList[i][1]<<endl;

		}
	}


	while (x < 800000)
	{
		//set x%1000 into p
		p = x%1000;

		//if p == 0, it means x is at a number ending in 3 zeros..., so go check preList to see if process is ready to come in or not
		if (p == 0)
		{
			
			//if 'arrivalTime' field in preList is equal to the current time in 'x', copy over into "readyList"
			if (preList[i][0] == x)
			{

				readyList[z][0] = preList[i][0];
				readyList[z][1] = preList[i][1];
				
				cout<<readyList[z][0]<<"   "<<readyList[z][1]<<endl;
				z++;
			}
			
		}
	
		x++;
	}


return 0;

}