in reply to compare two files and update

You have a logic problem and a design problem.

Logic problem: read 1st line of update file; read first to last lines of master file; read 2nd line of update file; oops - nothing left to read from master file.

Design problem: processing the entire master file for every line of the input file - MishaMoose alluded to this (above).

Try creating a hash (say %index) then read through the update file only and for each line store the data in the hash ($index{$key} = $line;). Next, read through the master file and for each line process its key against $index{$key}. That way you only read the files once.

Be aware, this assumes that the keys are unique!

-- Ken