Yes, seek works in this case because the final output is longer than the initial output. But a word of caution is in order. Consider:
my $filename = 'test.txt';
open(my $fh, '>', $filename) or die "Cannot open file '$filename' for
print $fh "The quick brown fox jumped over the unfortunate dog.";
seek $fh, 0, 0;
print $fh "The final output.";
close($fh) or die "Cannot close file '$filename': $!";
This results in file “test.txt” containing:
The final output.ox jumped over the unfortunate dog.
as seeking to the beginning of the file does not erase its existing contents.