Basically he was the "legal" owner and you are the "equitable" owner. It sounds as though the ex-husband discharged his liability on the debt in the bankruptcy. Based on the limited facts presented in your question, I must assume that either you stopped making payments on the house or it was past due at the time the ex-husband filed bankruptcy, as most banks don't usually foreclose if the payments are current. An attorney would need to look at the foreclosure papers and see why your name was "hand written in," as you stated, who wrote it in, etc. One can only assume based on these facts that you were "written in" so that the bank gave you proper notice so they may evict you after the foreclosure. However, this will be based on state property law in your state, as it differs from state-to-state. If you have only been "written in" for this purpose then your credit should be OK, as you are not an obligor on this loan. However, I urge you to seek advice from a competent attorney in your state to be on the safe side.
Jack Gillis, M.B.A., J.D.
Jack Gillis Realty Advisors
Nathan Grace Real Estate, Broker
5619 Dyer Street | Suite 100
Dallas, TX 75206