Long time lurker, first time poster.

I know helping with homework isn't this websites real purpose, but I am completely stuck.

This is my first semester with C++ and we learned about while loops, and my homework was to was to read a file and perform several task with the integers inside and write the results to a output file. The one that I'm stuck on is finding the smallest and largest integer and writing them to the output file.

I've tried if/else statements in a while loops, nest while loops, but I just cant figure out how to go about this.

My latest attempt was

while(Filein)
{
while(Num < Num2 || Num < Num3)
{
Num3 = Num;
Filein << Num;
}
Filein >> Num;
Filein >> Num2;
}


This was my attempt at finding the smallest integer and assigning it to Num3. But as I've noticed it does not work, and don't really know where to go from here. Please help.