When someone dies it can be difficult to know what to say in your first language. Therefore in your second language even more so. The main reason for expressing sympathy is to offer concern and compassion to the person who has had someone close to them die.
What to say:
I'm so sorry for your loss.
How are you doing?
I'm here for you, if you want to talk.
This must be so hard for you.
Let me know if I can do anything for you.
What to write:
Thinking of you at the this most difficult time.
In deepest sympathy.
My/Our thoughts are with you and your family.
What not to say:
At least he/she had a long life.
I know how you feel.
There is a reason for everything.