Skip to main content
4 of 5
It seems changing file metadata is considered enough for solving the problem, so...
g4v3
  • 241
  • 1
  • 4

Perl 5, 27 32 22 bytes

{{open my$h,'>o'}redo}

If simply changing the modification timestamp of a file suffices...

Quick explanation:

{ # Braces implicitly create/mark a loop.
    { # New, more localized scope, for `my` variable.
        open my $filehandle, '>', 'o';    # Writing to file "o".
        # close $filehandle;   # Called implicitly when
                               # variable gets destroyed.
    } # Scope gets destroyed; so does $filehandle.
    redo; # ...the loop.
}

Previous solution (32 bytes): {{open my$h,'>o';print$h 1}redo}

Edit: {open F,'O';print F 1;redo} ← Didn't test the code before posting; now I had to correct it.

g4v3
  • 241
  • 1
  • 4