To what
@HopesGaming said, I'll add :
7) Write in two steps.
You'll rarely be good right from the start, so don't try to be it. At first, write the whole scene without paying too much attention to the characters. Then, once the scene looks good and coherent for you, go back to the start and rewrite each line according to the character.
It will need more time, but it will also ease your works. The first time you focus on what the character will say, and the second time you'll focus on how it will say it. This way, things will come more naturally than if you try to figure out both at the same time.
8) In case of doubt, say it out loud ; if you can have someone reading the other character's lines for you it's even better. A sentence can feel good when you write it, but end being totally unnatural. And the best way to discover this is to ear the said sentence.
If you pain to read the whole sentence, if it feel forced when earring it, whatever how good it can look on the paper, it should be redone. This especially for dialogs. If you loose your breath before the end of the sentence, then it's not something that you'll ear in real life.