in reply to multi-line in-place edits
perl -pi -e '1 == $. and s/^/{/; eof and s/$/}/' file.txt [download]