(4)The master of every ship to which this section applies shall produce to the customs collector from whom a port clearance for the ship is demanded the certificate or certificates required by the foregoing provisions of this section to be in force when the ship proceeds to sea, and the port clearance shall not be granted and the ship may be detained until the said certificate or certificates are so produced.