I wrote for 6 years before I sold to Avalon. During that time I wrote and learned and wrote some more and learned some more. An ongoing process as we all know . . .
One important thing I learned is how long it takes me to write a book and what my method is. This is valuable knowledge for a writer because when that first sale comes along and with it the first contract, you have a clear idea of what you can manage and in what timeframe.
Publishers buy an author not just one book. They want to know they can rely on their new author to produce good quality, clean, ready to go work, on time as per the contract. Regard your unpublished time as an apprenticeship. This is when you learn not only your trade but about yourself.
Another bonus was that with 6 years of writing behind me I had a nice pile of stories to offer my publisher one by one with only minor revisions needed to suit the house guidelines. No stress involved. I also had vastly improved writing skills to bring to the revision of each suitable, completed manuscript. Suddenly I have 7 books out or in the pipeline.
I'm glad I didn't sell that very first story that went off only to be rejected. I wasn't pleased then despite some nice comments about it, but in hindsight it was a very good thing.