Need Help with Pascal

This is the question... Must use pascal.. 


Assume that a file containing a series of integers is named as numbers.txt and exists on your computer's disk. Write a program that determines the largest and the smallest number stored in the file. Then write the largest number and smallest number back to the same file.


I'm so lost... Any help would be appreciated 

So what you can do, (not the most efficient way) is read the file line by line or splitting the single line then go through and sort. A bit of this in logic outline would be:

int largest = 0; int smallest = 0;

int[] numbers  (You get this from splitting or reading the file);

for each int in the array of numbers (loop)

  if(number[index] > largest){

   largest = number[index];

 }else if(number[index] < smallest){

   smallest = number[index];

}

I'm sorry but I don't know Pascal myself, so I just browsed through a few tutorials and wrote what I know is fairly universal.