how to do animation using glut

I am displaying a set of line using my display function as following

void display()
{

glClear(GL_COLOR_BUFFER_BIT);	
glColor3f(1,0,0);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity();
glRotatef(-90, 1.0f, 0.0f, 0.0f);


double tt=10;
glBegin(GL_LINES);

  for(float i=0;i<10;i=i+1)
  {
	 for(float j=0;j<1;j=j+1)
  {
	 
	tt=10;
	for(int k=0;k<temp.size();k++)
	{

	if(i==temp[k].x && j==temp[k].y)
	 {
		 tt=temp[k].z;
	 }

	}
	  glVertex3f(i,0,0);
	  glVertex3f(i,0,tt);
  }

  }
  glEnd();
  glutSwapBuffers();

}

where temp is vector containing the following data
0 0 5
1 0 6
2 0 7
3 0 8
4 0 9
5 0 10
6 0 2
7 0 3
8 0 4
9 0 5
10 0 6

i want the lines to be displayed one by one.
The way i have written the code is that it compares all the line coordinates in one instance and then displays it.
Please suggest a modification.