write out ver.txt after everything has completed ok

Seems to work for me. (I don't believe there's any need to write it out temporarily; it should reflect what is successfully built (not what was attempted)).