It can always be difficult to stay motivated to write. What I've found to be helpful is I keep reading, whether it's a book, a short story, an article, or fanfiction. I read, because that always seems to give me new ideas for whatever I'm stuck on writing at the time. Either that, or it gives me time to clear my head and not think about being stuck on writing. By distracting myself with reading, my head gets cleared and ideas come forward that I hadn't been able to think of before.
So whatever you're writing, whether it's a story or poem, put it down for a bit and read something else and see if ideas will come to you that way.
Another problem for writers can be weaknesses and things they habitually forget to do while writing. One of my weaknesses in writing is I always forget to go back and read what I wrote to check the spelling and grammar. It has been such a problem in the past that if I'm writing a paper or anything, now I will always read it over at least twice before I print or email it.
This has almost been the downfall of many things I've written and I was beating myself up over it every single time. Luckily, I'm improving and trying to break my habit.
If you have a habit that causes problems with your writing, try and figure out what the problem is and how you can fix it, then have a reminder that you will see all the time while you're writing and eventually that bad writing habit may be broken. If you're able to break that bad habit, then you're one step closer to even better writing.