OK I have decided to write an answer besides a comment.
You can use the i command of sed like:
sed -i '1i \ # The latest IANA port assignments can be gotten from\ # http://www.iana.org/assignments/port-numbers\ # The Well Known Ports are those from 0 through 1023.\ # The Registered Ports are those from 1024 through 49151\ # The Dynamic and/or Private Ports are those from 49152 through 65535\ #\ # Each line describes one service, and is of the form:\ #\ # service-name port/protocol [aliases ...] [# comment]' file The is for GNU sed. For sed on Macs you need to use sed -i''i '' -e ..., and for POSIX sed there is no simple way to do things in place.