"Why can't you just write what you hear?"
Not to mention "why can't you just hear what you write?"...
I ain't gonna moralise here (which is wise of me, since I ain't very moralistic), but I never write at an instrument (piano, violin, computer et al) so I do write what I hear and I hope I get it right on occasion.
But to answer the question as posed: "with difficulty" (not so much for technical reasons but for others to which any composer will surely attest and with which any will doubtless readily identify).