2nd in foreclosure with a current first

Does anybody know what happens after the sheriff’s sale when the junior lender forecloses and the first mortgage is still current? Who gets title the property following the sheriff’s sale assuming no investor buys it?

Thanks,

Paul

the 2nd mortgage holder, however, typically, the 1st would buy it out at the auction or pay it off during redemption.