They are not sorted.
The first step of your rexx program should be to sort the files.
Based on the sizes of the files, I would try to only read FileB only one time.
You should index FileA something like this, which builds an array of keys in fileA:
allkeys. = 'null'
EXECIO ... (STEM filea.
Do ix = 1 to filea.0
keyA = substr(filea.ix,27,8)
allkeys.keyA = keyA
End
Then as you read in records from FileB, see if there is a match:
keyb = substr(fileb,27,8)
If allkeys.keyb ^= 'null' Then ...