Using the FileIO() UDF will make this a bit easier. FileIO can read a file into an array, then write that array to a file (same or different). The advantage, besides having a single UDF, is that when FileIO is used to write, you can suppress writing blank lines with a simple parameter. Thus, simply enumerate the first (master) file. Each line should then be searched for in the other file (array). If there's a match, simply set the element in the second array to an empty value. The example below illustrates this using a flat delimited dataset for the master data.

 Code:
; variables should be declared!
$aFData1 = FileIO($Source1, 'R') ; read the first (Master) file
$aFData2 = FileIO($Source2, 'R') ; read the second file

; Convert the master file to a delimited string to simplify matching the second file array
; The source will look like "~line1~line2~line3~...~"
; The delimiter character chosen MUST NOT appear in the source data. Use "Chr(3)"
; as a non-text delimiter if this is an issue (replace "'~'" with "Chr(3)" in this example)
$Source = '~' + Join($aFData1, '~')

; Enumerate the file to "clean up" - lines that exist in file 1 will be removed
For $P = 0 to UBound($aFData2)
  ; If the current line "~line#~" is found in $Source, clear it!
  If InStr($Source, '~' + $aFData2[$P] + '~')
    $aFData2[$P] = ''
  EndIf
Next

; All dups have been removed from the second file - write it back, trimming blank lines
$aFData2 = FileIO($Source2, 'W', 2)
FileIO() has some useful options, such as suppression of blank lines, suppression of final line terminator, and ability to output LF-delimited files for use on *nix systems.

Glenn

PS - the latest version of FileIO() can be downloaded from my http://www.innotechcg.com web site. Grab it now as I'm shutting this domain down and migrating the Kix library to a personal domain in the next few days.

_________________________
Actually I am a Rocket Scientist! \:D