perl -i -ple'BEGIN { print "new text" }' file