See #982: - Removed unnecessary lopping in order to find a new log file name - Refactoring: Moved invariant lines outside the loop - Changed format for milliseconds