Assuming you put a clause in the contract that says "you can have source code and the rights to do [X,Y,Z] with it but we still own it", you might also consider having a clause that says "any changes you make to this code must be fed back to us and we have the right to include them in a future release of the code".
This means that if you do have a continuing long relationship with them, that
you can get bug-fixes and extensions that their coders for free; and
that you won't have the maintenance nightmare 5 years down the road of many many versions of the same code.
Assuming you put a clause in the contract that says "you can have source code and the rights to do [X,Y,Z] with it but we still own it", you might also consider having a clause that says "any changes you make to this code must be fed back to us and we have the right to include them in a future release of the code".
This means that if you do have a continuing long relationship with them, that