Searching through files issues

Hello! Im new to this forum and Im having some issues with this program, Im new to coding and I would like to know if there is something wrong about this.
The issue I currently have is that it never ends the executing progress and it freezes kind of.
This program searches for a code of a subject in a txt file and then searches in another txt file whats the code of the student which is currently coursing that subject and also searches in another txt file, what major is the student doing.
I hope to find some solutions and tips, thanks!


void asignaturas(String^ codA)
{
StreamReader^ lee = gcnew StreamReader("matricula.txt");
String^ linea = "";
while(lee->Peek() != (-1))
{
String^ codE = "";
linea = lee->ReadLine();
array<String^ >^vec = linea->Split(';');
if (codA == vec[1])
{
codE = vec[0];
}
StreamReader^ lee2 = gcnew StreamReader("estudiantes.txt");
String^ linea2 = "";
while(lee2->Peek() != (-1))
{
linea2 = lee2->ReadLine();
array<String^ >^vec2 = linea2->Split(';');
String^ codP = "";
if (codE == vec2[0])
{
codP = vec2[3];
listBox1->Items->Add(vec[2]);
}
StreamReader^ lee3 = gcnew StreamReader ("programas.txt");
String^ linea3 = "";
while(lee3->Peek() != (1))
{
linea3 = lee3->ReadLine();
array<String^ >^vec3= linea3->Split(';');
if (codP == vec3[0])
{
listBox1->Items->Add(vec3[1]);
}

}
lee3->Close();
}
lee2 ->Close();
}
lee->Close();
}




@Walteremcy (1)

You have just been added to my list of potential trolls to be reported to admin.
Topic archived. No new replies allowed.