Fixed crash when logging errors into a file