Any sum of money remaining in said fund after defraying all necessary expenses of location, entry, surveying, platting, advertising, filing and recording, reimbursement of moneys loaned or advanced and paying the cost and expenses herein authorized and provided for must be deposited in the county treasury by such judge to the credit of a special fund of each particular town, and kept separate by the county treasurer to be paid out by him or her only upon the written order of such judge in payment for making public improvements, or for public purposes, in such town.