<prompt> Human: I have been reading up on personal finance now that I am about to enter the real world. Was reading up on foreclosures and there is something Im really confused about:If a persons house is foreclosed and taken over by the mortgage company, I just read that the mortgage company does Not have to pay the person the excess difference in sale price and loan price if there is one. However, if the outstanding loan is more than the sale price, the owner still might have to pay.Now can someone please explain to me what I am misunderstanding here? It seems like the mortgage company has everything to gain, for it is keeping any potential profit off a foreclosure. The homeowner has everything to lose because he loses his deposit what?!, and any excess is kept by the mortgage company.Isnt that unfair?  <response>: It would be very unusual for a bank to actually profit off the sale of a foreclosed property. Most foreclosures occur because the owner is underwater and unable to sellrefinance. Furthermore, by the time the foreclosure process is completed which can take years, many of these properties have already deteriorated to the point where they are worth a fraction of what they were before the owners stopped paying.There are also a lot of costs associated with foreclosure that can eat into any profit the lender might be able to squeeze out of the property - such as legal fees, property taxes, and basic property maintenance. The towncity can also fine the lender for various code violations associated with the property if applicable. 