JayBonci is right -- something like mySQL is the best approach.
But you say you were asked to "build an output file which combines
all the information in all of the input files", so in that
context, I think your idea would be hard to improve on, so
long as you're careful to use an appropriate delimiter
between the fields on each line (i.e. something that doesn't
show up as data within any of the fields), and have a sensible
way to deal with gaps -- a blank field in a given column for
a given row.
Also, if the patterns in different columns tend to be
"confusable" (e.g. a search pattern for one type of field
happens to match values in another field), you'll need an
enhanced "grep" process that can limit the search to a
particular field.