How to compare two text file. If compare is match then copy the match file

Please provide me the code how to compare two file . Suppose there are 3 file.We compare file1 with file2 line by line(Row wise). Suppose i compare logonid(unique) of file1 with file2. If logonid is match then copy the entire row to file3. Please tell me the what is the code for it.

[297 byte] By [minatia] at [2007-11-27 11:46:23]
# 1

why?

TuringPesta at 2007-7-29 18:07:17 > top of Java-index,Java Essentials,Java Programming...
# 2

Wow, so minati is both lazy and inconsiderate. Nice.

jverda at 2007-7-29 18:07:17 > top of Java-index,Java Essentials,Java Programming...