searching data inside the text file

hi good day , smile emoticon we have a project that we need to search the data inside the text file and compare it to the card_id. The problem is, only the first line of the text was being match it will not go further to the next line.

inside the text file:
9123821|benz
0908823|noel
4rf554gf|amber

here's my code:

myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");

// read from the file until there's nothing else in it:
while (myFile.available()) {
String line = myFile.readStringUntil('\n');

String type = get_value(line, '|', 0);
String Name = get_value(line, '|', 1);

if (type == card_id)
{
Serial.println(type + "|" + Name);

card_id="";
Serial.println(F("Welcome, You shall pass"));
granted(300); // Open the door lock for 300 ms
}
else { // If not, show that the ID was not valid
card_id="";
Serial.println("error opening test.txt");
}
break;
}
}
// close the file:
else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}

example :

card_id is 0908823

it will print :

0908823|noel

Please respect. Thank you and God bless. :slight_smile:

Why do you break out of the while loop when you compare a record, regardless of whether or not a match was found?