diff --git a/flang/runtime/unit.cpp b/flang/runtime/unit.cpp --- a/flang/runtime/unit.cpp +++ b/flang/runtime/unit.cpp @@ -834,7 +834,7 @@ } void ExternalFileUnit::DoEndfile(IoErrorHandler &handler) { - if (access == Access::Sequential) { + if (IsRecordFile()) { endfileRecordNumber = currentRecordNumber; } FlushOutput(handler);