log file was only keeping last line written, fixed