open FH, "+< $filename" or die $!; seek FH, 0, 0 or die $!; print FH "sm.th."; # printing to the first line