You have to choose your words wisely. When I had a miscarriage I wasn't really receptive to anything anyone had to say, unless it was something I didn't want to hear. Anyways, the best thing for you to say is, "I'm sorry to hear what happened. If there is anything you need, please don't hesitate to ask." Don't every say, "Maybe it wasn't meant to be" or anything along the lines of you can always try again.