All persons who shall have settled and made valuable and permanent improvements upon any odd-numbered section of land within any railroad withdrawal in good faith and with the permission or license of the railroad company for whose benefit the same shall have been made, and with the expectation of purchasing of such company the land so settled upon, which land so settled upon and improved, may, for any cause, be restored to the public domain, and who, at the time of such restoration, may not be entitled to enter and acquire title to such land under the homestead laws of the United States, shall be permitted, at any time within three months after such restoration, and under such rules and regulations as the Secretary of the Interior, or such officer as he may designate, may prescribe, to purchase not to exceed one hundred and sixty acres in extent of the same by legal subdivisions, at the price of $2.50 per acre, and to receive patents therefor.