Fix log file writing error
Improve version number extraction.