You have a contract with the landlord. You are obligated to pay that rent as provided in the contract even if the landlord does sell unless the landlord agrees to terminate it. The landlord could, for example, transfer the contract to the new property owner if the new owner if you both don't agree to terminate it earlier.

