Listing 3 Pseudocode for a procedure to merge two text files

/* Program to merge two sorted files */

open and read first line from each file
while (neither file has been exhausted)
{
   determine which line comes next
   print that line
   get a fresh line from the corresponding file
}

empty the remaining active file, if any
close files

/* End of File */