When it comes to saving for retirement, many Americans are clearly falling short. In fact, an estimated 42% have less than $10,000 set aside for the future. What's even more disturbing, however, is that a large number of Americans have no nest egg at all, and for 22%, the reason boils down to having depleted their retirement funds to cover emergencies, according to GOBankingRates.

The problem with tapping a retirement plan to cover immediate expenses is twofold. First, the more money you remove at present, the less savings you'll have available to use in retirement when you're (potentially) without an income.

Additionally, unless you happen to qualify for an exception, taking an early withdrawal from a retirement plan -- i.e., removing funds prior to age 59 1/2 -- means facing a 10% penalty on the amount removed. In other words, if your car breaks down and your only means of covering that repair is a $5,000 withdrawal from your IRA, you'll lose $500 of that as a penalty if that distribution is taken at a time when you're younger than 59 1/2.

Middle-aged man writing in notebook while woman looks on.

IMAGE SOURCE: GETTY IMAGES.

Clearly, removing funds from an IRA or 401(k) for non-retirement purposes is a bad idea. But when you're stuck in a situation where you're desperate for money, it might seem like a better alternative to, say, racking up debt to cover an unplanned bill. An even better solution, however, is to build an emergency fund. The sooner you do, the less likely you'll be to tap or deplete your nest egg the next time you're strapped for cash.

You need that safety net

Financial emergencies happen to everyone, and they tend to spring up out of nowhere (hence the whole "emergency" component). That's why it's critical to have at least three months' worth of living expenses in the bank at all times. This way, you have a cushion if a home repair, medical bill, or other expense exceeds the amount you bring home in your paycheck.

For even better protection, however, you might choose to sock away more like six months' worth of living costs in the bank. If you're laid off from your job, for example, having a six-month cushion might tide you over while you look for work, all the while preventing you from accessing the money you've already set aside for retirement.

Where will that emergency fund come from? There are several ways you can build one fairly quickly. First, examine your budget or create one if you don't have one already, and identify some expenses you can cut either temporarily or even on a long-term basis. For example, if you're starting with virtually no money in the bank, you might pledge to cancel your cable plan, stop dining out, and reduce your leisure spending until your emergency savings are in a healthier place. Or you might make a more life-altering change, like downsizing your home or getting rid of a car you can technically do without. The key is to free up enough cash to build some reserves in the bank.

Another option you might explore involves getting a side hustle. The beauty of having a second job is that the money you earn from it won't already be earmarked for other expenses. As such, you should have no problem banking all of it.

Finally, take whatever windfalls you get during the year and use that cash to boost your savings. That could mean banking your bonus at work or sticking your tax refund directly into savings rather than spending it on a vacation like you normally would.

Having emergency savings will help you avoid a scenario where you're compelled to touch your nest egg for non-retirement purposes, and that's why building some should be your primary financial priority -- more so, in fact, than adding to your IRA or 401(k). Though putting money into a retirement plan is a responsible move in its own right, you should first focus on your emergency fund and then concentrate on building savings for the future. This way, you'll avoid the penalties that come with accessing retirement funds early and buy yourself some peace of mind in the face of life's unknown expenses.

The Motley Fool has a disclosure policy.