I would change
do
{
fscanf(fp,"%d\t\t%s",index,student.firstname);
length = strlen(student.firstname);
if(student.firstname[length]==studentname[length])
found=1;
}while(!feof(fp));
to
while !feof(fp)
{
fscanf(fp,"%d\t\t%s",index,student.firstname);
length = strlen(student.firstname);
if(student.firstname[length]==studentname[length])
break;
}