Loneliness is a matter of point of view, it doesn’t matter whether you have a spouse or not, if you can fill your life with happiness everyday you will never feel lonely. The best way to get rid of loneliness is by having a passion. You should be interested in some subject or career, so when there is no one left to fall back on, you will still have passion to reach so you will keep going on and moving forward. When you wake up everyday, the only thing you should think about is how you can reach your goal, not why you are single and you feel lonely.
You should know that lots of married people out there are feeling lonely because they are not married with the right person, or simply because they don’t want to work on their marriage’s happiness. When you are having a spouse, it doesn’t mean that you are having fun in life. Happiness in marriage takes sacrifice, two people should have understanding and they shouldn’t expect only one side to make them happy. If you want to be happy, make your spouse happy too. And again, marriage is not the key not to feel lonely in this life, but passion is.