Want to know what to write? Write every permutation.
Write a two-bar musical line. Try every rhythmic variation on what you’ve written. Dotted. Backwards dotted. Triplets. Connected. With breaks. Longer last note duration. Shorter.
Write it upside down. Write it backwards. Expand and contract the intervals. Try it slower. Try it faster.
In short: find out what the line wants to be. When you know everything it could be, what it should be will be more obvious. Then you can move on to the next phrase.
(This gets faster. Your intuition and instinct will get better. And you’ll get better at knowing which phrases need this much attention and which ones just need to be “good enough.”)