if then (*konets serii*texts write( "|")inc(nendx : endtexts write( "$")texts writeint(wk )texts writeint(wn )texts writeln(wend listseqend runs we now return to the process of successive refinement of the process of natural merging procedure copyrun and the statement merge are now conveniently expressible as shown below note that we refer to the sequences (filesindirectly via the riders attached to them in passingwe also note that the rider' field first represents the next key on sequence being readand the last key of sequence being written procedure copyrun (var xyruns rider)begin (*copy from to *repeat runs copy(xyuntil eor end copyrun (*merge from and to *repeat if first first then runs copy( )if eor then copyrun( end else runs copy( )if eor then copyrun( end end until eor or eor the comparison and selection process of keys in merging run terminates as soon as one of the two runs is exhausted after thisthe other run (which is not exhausted yethas to be transferred to the resulting run by merely copying its tail this is done by call of procedure copyrun this should supposedly terminate the development of the natural merging sort procedure regrettablythe program is incorrectas the very careful reader may have noticed the program is incorrect in the sense that it does not sort properly in some cases considerfor examplethe following sequence of input data by distributing consecutive runs alternately to and bwe obtain these sequences are readily merged into single runwhereafter the sort terminates successfully the examplealthough it does not lead to an erroneous behaviour of the programmakes us aware that mere distribution of runs to serveral files may result in number of output runs that is less than the number of input runs this is because the first item of the + nd run may be larger than the last item of the -th runthereby causing the two runs to merge automatically into single run although procedure distribute supposedly outputs runs in equal numbers to the two filesthe important consequence is that the actual number of resulting runs on and may differ significantly our merge procedurehoweveronly merges pairs of runs and terminates as soon as is readthereby losing the tail of one of the sequences consider the following input data that are sorted (and truncatedin two subsequent passes