Yes, that's a race condition.
The problem is that the shell starts all processes in the pipeline at the same time and tee truncuatestruncates the output file on startup. If tee is faster then comm the file is empty for comm otherwise it is not.
The pipeline behaviour can be seen if you run this several times (mabe in a loop):
date '+first: %T'|(cat>&2;sleep 5)|date '+second: %T'