diff --git a/flang/runtime/io-stmt.cpp b/flang/runtime/io-stmt.cpp --- a/flang/runtime/io-stmt.cpp +++ b/flang/runtime/io-stmt.cpp @@ -318,8 +318,13 @@ if (!mutableModes().nonAdvancing || GetIoStat() == IostatEor) { FinishReadingRecord(); } - } else { + } 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();