Well, you don't bother checking the return value of fopen. Could that be it?

Oh, and you open "comm.txt" twice! Once in main and once in mac.

And what's up with all the pointless globals?
...