Here's some pseudo-ish code, just whipped together/untested:
 Code:
; Load both files into arrays
$aFileA = FileIO('fileA.ext', 'R')
$aFileB = FileIO('fileB.ext', 'R')

; Enumerate File A
For Each $Line in $aFileA
  ; Detect when the line is a header - look for something that identifies a header
  If InStr($Line, "header stuff:") ; found a header
     ; might need to split off the header part?
     $Header = Split($Line, ':')[0] ; assumes that the headers looks like "1, Header stuff: other stuff...) - take everything up to the ':'

     ;Look in the other file for a line containing the same header
     $Target = AScan($aFileB, $Header) ; check args here - might want a partial match
     If $Target <> -1 ; was found!
       ; $Target is the line number in File B's array - read that and extract data until the next header is found
       For $P = $Target to $Target + 999 ; scan next 999 lines or till we find the next header
         If $P > $Target And InStr($aFileB[$P], 'Header stuff') ; found the NEXT header
           $P = $Target + 1000 ; terminate the loop
         Else
           $aFileB[$P] ? ; output for testing, manipulate if necessary
           ; This line from File B has data for a matching header. You may need to 
           ; split the File B header ($P = $Target means this is the header line in File B)
         EndIf
       Next
     EndIf
  EndIf
Next
The FileIO reads a file into an array, can also write an array to a file. Download from the UDF library on my web site (see sig).

Glenn
_________________________
Actually I am a Rocket Scientist! \:D