If you really want to learn what to say, spend some time reading What To Say When Someone Dies, a magnificent blog by writer and editor Teresa Bruce. Ms. Bruce is a widow, so she speaks from experience.
I know of few better resources anywhere for comforting the mourner. a mitzvah which we call in Hebrew Nichum Avelim (nee-CHUM ah-veh-LEEM.)
Jewish tradition reminds us that our presence is the main thing we have to offer. There is a human impulse to run away, to avoid, and we must fight that impulse with all our might, because there are few things more cruel than to abandon a mourner. Mourners bear the weight of loss, and they deserve our support. We can express that support by showing up, by reaching out, and sometimes simply by being there in silence. But sometimes we need to know what to say, or how to say it: that’s where Ms. Bruce’s blog is such a gift.
There are a lot of entries. Use the tools on the side: search box, categories. Find the things that will help you in your current situation. She covers many situations, and you can leave her a question in comments if you can’t find the help you need.
So go, read, learn how to be there for the mourners in your community! If you don’t know any now, the day will come and you don’t want to be caught flat-footed! This is a mitzvah we can all do, and with such gentle instruction, we can do it well.