perl -pi -e '1 == $. and s/^/{/; eof and s/$/}/' file.txt