"I am writing him a love letter."
Translation:Je lui écris une lettre d'amour.
You're writing it to him, so that would be the indirect object. The pronoun for "il" when it is the indirect object is "lui".
If you were to change the sentence and assume that you've already mentioned the letter but not the person you're writing it to you could say "je l'écris à Paul" (I'm writing it to Paul). The letter is the direct object and so the pronoun is "la" which gets shortened to "l' ".
Maybe I can explain better like this:
Who is doing the writing? --> subject of sentence (je, tu, il/elle, nous, vous, ils/elles)
What is being written? --> direct object (me, te, le, la, nous, vous, les)
Who is it being written to? --> indirect object (me, te, lui [for both masculine and feminine when in front of verb], nous, vous, leur)
In this cause is it okay for lui and écris to be near each other? I thought because lui ends with a vowel and écris starts with a vowel there would be a change.
I wrote "J'ecris une lettre d'amour a lui" and it was counted wrong. Can you phrase it this way too?