"He writes a book for her" is the literal translation but is not accepted.
but it makes sense that literal traslation as native english?
Yes, I agree: "He writes a book for her" is a literal translation and is very natural in native English. The program ought to accept that.
At first glance I thought that "He writes a book for her" was ok, however it doesn't sound well enough, so I consider that "He writes her a book" is far better than the other one
Never heard that said in english. He writes her a letter would be more usual. No one i know sits down and "writes her a book". It kind of implies he had a lot to say to her. Could say, a book of somthing, like poems for example