Most people who have ever lent money to friends or family will give those considering lending a hand one piece of advice: Don’t do it. 

“I think lending money is often a band-aid solution to some bigger problem,” says Vic Lim, a personal finance writer and founder of DadIsCheap.com. “Does this person not have a job or decent savings? I would much rather help that person fix those problems than provide them with money.”

When a friend or loved one is in a bind, it can be hard to turn them down, though. If you’re going to lend money to a friend, you at least want to be prepared. Here are five rules to follow to help make a difficult situation easier.

1. KEEP PERSONAL FEELINGS OUT OF IT (TO THE EXTENT YOU CAN).

Lending money often goes south because both parties establish a too-casual agreement, and it’s easy for a casual agreement to fall through.

“Not being paid by anyone makes us angry. Not being paid by someone with whom we have a close relationship makes that anger personal,” attorney J. David Krekeler says.

With a regular commercial loan, the lender investigates the borrower’s assets and credit history; they weigh their risk. When you lend money to a friend, it’s more of a favor than a business transaction. However, Krekeler explains, this is often where things go wrong. “When the loan goes into default, the lender feels not only the financial loss but a personal disappointment,” he says. “Often, failure to repay signals to the lender a lack of integrity, or even a personal attack by the borrower upon the lender. Feelings of deception might also enter into this.”

2. MAKE IT OFFICIAL.

Krekeler suggests first getting the agreement in writing. In other words, make a contract. It should include the amount being lent, interest charged, and terms of repayment. And if charging interest sounds harsh, keep in mind that the Internal Revenue Service (IRS) actually requires it.

“If you do not charge interest, it may be imputed by the IRS and treated as income even if the lender does not receive it,” Krekeler says. “It is better to use at least the IRS minimum interest rates.”

3. DRAFT AN EXIT PLAN.

Beyond just writing up a contract, you also want to draft a concrete exit plan for the loan. For example, Krekeler suggests considering the following factors:

1. What would happen if the borrower loses his or her employment or source of income?
2. What effect would a divorce have upon the borrower?
3. What problems would a catastrophic event such as a medical disaster or an auto accident in which the damages exceed policy limits create?
4. How will this loan be treated if the borrower should ever have to file bankruptcy? 

Beyond that, asking for collateral may also be a good idea. It may be awkward, but it can save a load of headaches down the road.

“In my experience, the lender will typically not want to have collateral, but having collateral might well ensure that the loan eventually is repaid. It can also put the lender in a better position than the borrower’s other creditors,”  Krekeler says. “This, of course, seems insignificant at the time the loan is made, but can be of great value later when the borrower has financial problems. Having a friendly party holding liens upon the debtor’s assets can be a valuable tool, not only for the lender, but for the borrower as well.”

If you’re dealing with a substantial amount of cash, you might even want to enlist the help of an attorney, or at least have an attorney review your contract and plan.

4. DON’T LOAN WHAT YOU CAN’T LOSE.

You also don’t want to stretch your own finances thin in order to supplement someone else’s. “Only lend what you can afford to give, not how much your friend needs,” Lim says. “You don't want to overextend your own budget helping someone else.”

And of course, make sure your partner or spouse is aware of the loan. “I have seen many instances where one spouse lends to a family member without the consent of the other spouse,”  Krekeler says. “A later default then leads to even more personal pressures on both borrower and lender.”

5. BE PREPARED FOR THE LOSS.

Finally, even with a contract and a plan in place, you should always be prepared for the worst. If you want to keep the friendship intact, it may help to ultimately view the loan as gift.

“If your friend is unable to pay you back, the relationship wouldn't be ruined because you weren't expecting to get back that money anyway,” Lim says. “If your friend avoids your inquiries or conveniently ‘forgets’ that they owe you, I would consider it a lesson learned and move on.”