One thing that's always kept me writing - no matter how much money I make or don't make - is the enjoyment that I get from the writing process. Even if I never sell another script I'm still getting something out of the experience because I'm working on projects where I enjoy the process.
One thing I learned early on was that you have to make sure that worst case scenario isn't too bad. In other words assume the script won't sell and make sure you're still going to get something out of it.
I've been in many situations where I've written scripts that I was only half-way interested in or I've made changes to one of my scripts that I didn't believe in all to satisfy a producer. The producer would make big promises which most of the time never materialized, in which case I was left with absolutely nothing. So I've really made a conscious choice to try and only work on scripts that I'm really interested in, that way when they don't sell I still got something out of the experience.
Ashley at SellingYourScreenplay.com