Filing for bankruptcy and losing your home do not have to go hand in hand.
If there is no equity in the property, you will likely be able to keep it, as long as you continue to pay your mortgage. However, keep in mind that if you don’t pay, the lender retains the right to foreclose.
If there is equity in the property, a bankruptcy attorney can usually help you protect that equity by using exemptions that keep the property safe from your creditors and the bankruptcy trustee. If the equity in your home is all exempt, you will be able to keep the property as long as you continue to pay your mortgage.
Make your payments and everyone involved will be happy. Your bank doesn’t want your house, it wants you to make mortgage payments on time.