Sometimes, the best thing to say is nothing at all. Or if you don't know what to say, then acknowledge this; "I don't know what to say" can be oddly comforting in its own right. Either way, what's important is to let the other person lead for a short while, and see if you can pick up cues as to what to do from their actions.

It took me years to learn this one, and I screwed up a more than one close friendship by not realizing it sooner. Trust me, it's worth knowing.