Index: flang/runtime/io-stmt.cpp =================================================================== --- flang/runtime/io-stmt.cpp +++ flang/runtime/io-stmt.cpp @@ -915,7 +915,7 @@ auto pos{unit().position()}; if (pos == size.value_or(pos + 1)) { str = "APPEND"; - } else if (pos == 0) { + } else if (pos == 0 && unit().mayPosition()) { str = "REWIND"; } else { str = "ASIS"; // processor-dependent & no common behavior Index: flang/runtime/unit.cpp =================================================================== --- flang/runtime/unit.cpp +++ flang/runtime/unit.cpp @@ -215,11 +215,13 @@ RUNTIME_CHECK(terminator, !wasExtant); out.Predefine(1); out.SetDirection(Direction::Output, handler); + out.isUnformatted = false; defaultOutput = &out; ExternalFileUnit &in{newUnitMap->LookUpOrCreate(5, terminator, wasExtant)}; RUNTIME_CHECK(terminator, !wasExtant); in.Predefine(0); in.SetDirection(Direction::Input, handler); + in.isUnformatted = false; defaultInput = ∈ // TODO: Set UTF-8 mode from the environment unitMap = newUnitMap;