diff --git a/flang/runtime/io-stmt.cpp b/flang/runtime/io-stmt.cpp
index fba77171062e..ac2a7e0a11ed 100644
--- a/flang/runtime/io-stmt.cpp
+++ b/flang/runtime/io-stmt.cpp
@@ -318,8 +318,13 @@ void ExternalIoStatementState
::CompleteOperation() {
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();