Depending on the file size you could just use
grep -Fxf A B
-f specifies a file from which to get a list of patterns.
-x means to match the whole line only (disallow matching a part of a line).
-F means to treat the patterns as fixed strings rather than regular expressions.
B is smaller than
A you may get slightly faster results by naming
B as the pattern file (
grep -Fxf B A).
You can pipe the output to
sort -u to get a sorted list of the distinct lines that occur in each file:
grep -Fxf A B | sort -u
Of course if your problem is carriage return line endings, you should use