Index: flang/runtime/io-stmt.cpp =================================================================== --- flang/runtime/io-stmt.cpp +++ flang/runtime/io-stmt.cpp @@ -329,8 +329,16 @@ if (!mutableModes().nonAdvancing || GetIoStat() == IostatEor) { FinishReadingRecord(); } - } else { - if (!mutableModes().nonAdvancing) { + } else { // output + if (mutableModes().nonAdvancing) { + // Make effects of positioning past the last Emit() visible with blanks. + std::int64_t n{unit().positionInRecord - unit().furthestPositionInRecord}; + unit().positionInRecord = unit().furthestPositionInRecord; + while (n-- > 0 && unit().Emit(" ", 1, 1, *this)) { + } + unit().leftTabLimit = unit().furthestPositionInRecord; + } else { + unit().leftTabLimit.reset(); unit().AdvanceRecord(*this); } unit().FlushIfTerminal(*this);