What you paid off for the mortgage has absolutely nothing to do with whether you had a gain or not. Mortgage payoff does not enter into the calculation at all. You have to report the sales price, among other things.
You report the Sale of a personal residence at:
Federal Taxes
Wages & Income
choose I'll choose what I work on, if asked OR Jump to Full List
Scroll down to
Less Common Income
on the
Sale of Home line, click start or update
then enter the necessary information in response to the interview
The purchase of a new personal residence is not a reportable event.
You can deduct mortgage interest, points, and real estate property tax paid at closing. You report those expenses along with other mortgage interest/property taxes paid in the year at
Federal Taxes (or Personal if using Home and Business)
Deductions And Credits
choose I'll choose what I work on, if asked OR Jump to Full List
My Home
All other costs paid at closing, including transfer taxes, "stamps", escrow fees, etc., are NOT deductible from current income, instead you add them to the cost basis of your home and you will get the benefit when you sell.