Fannie Mae, the housing lender bailed out by the government nearly a decade ago, needs a $3.7 billion infusion of taxpayer cash.

But it's not because of bad mortgages or plunging home values, as was the case during the financial crisis. In fact the housing market is white hot once again. The reason is the tax law enacted earlier this year.

Because corporate tax rates were cut, the value of future tax deductions it carries on its books is much lower than it otherwise would have been. That change forced Fannie Mae to take a $9.9 billion accounting charge in the fourth quarter. As a result it lost $6.7 billion overall.

Fannie Mae doesn't need to write a $9.9 billion check to the IRS. This is just a paper loss in its accounting statements.

A number of other companies, including large Wall Street firms such as Goldman Sachs (GS), have taken similar losses. The difference is that companies like Goldman have huge pots of money built up, and can shrug off paper losses.

But since the 2008 bailout, Fannie Mae has had to turn over any money it takes to the United States Treasury in the form of dividends, rather than use it to build up a pot of cash.

Related: Mnuchin says housing finance reform is a 'priority' for Trump administration

Fannie Mae had only $3 billion in capital on its books. So it needs a $3.7 billion federal cash infusion to cover the paper loss. It's the first time in six years that Fannie Mae has needed taxpayer cash.

It expects to start making money again, and when it builds up $3 billion again, it will start paying most of its profits to the Treasury.

Fannie Mae and Freddie Mac are companies created by Congress in the 1960s to help guarantee mortgages, lower borrowing costs and help more people buy homes. Collapsing housing prices and soaring foreclosures forced Congress to approve a massive bailout of the firms in 2008.

Overall, Fannie Mae has paid $166 billion back to taxpayers since the bailout. That's $50 billion more than Treasury spent on its bailout. Freddie Mac has paid back $112 billion, or $41 billion more than its bailout cost.