what is the output you got?, what is the problem you faced?.
UPDATE
from the code you shown above, it won't work as you expected.
because for every line(first column) in the file1 you are printing the only the second column match from file2.
grep will give only the matched indexes in this case
use hash instead
iterate through the second file and load the splitted line into a hash like the first column as key and second column as value(provided your second file is not in huge size)
then when you are iterating the first file, just check
exists in the hash, if exists append the hash value as the third column during print
hope this helps
Vivek
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.