The magistrate may make any orders on the examination, in reference to keeping the witnesses separate and apart, or excluding the witnesses during the examination of other witnesses or of the defendant, that the magistrate may think best for the attainment of justice, and shall, on demand of either party, put all witnesses under the rule.