Fix #637. Truncate log file if the last request wasn't written properly