diff --git a/flang/runtime/unit.cpp b/flang/runtime/unit.cpp --- a/flang/runtime/unit.cpp +++ b/flang/runtime/unit.cpp @@ -114,6 +114,7 @@ // Otherwise, OPEN on open unit with new FILE= implies CLOSE DoImpliedEndfile(handler); FlushOutput(handler); + TruncateFrame(0, handler); Close(CloseStatus::Keep, handler); } if (newPath.get() && newPathLength > 0) {