perl -i -wpe 'print "new text\n" if $. == 1;' file