3fe7959850
Use a temporary file to write the summary header and existing log content, then replace the original log atomically. This removes the dependency on sed for summary insertion and avoids unsafe string interpolation.