Inserting a comment in specific line with sed
First line:
sed -i 'i1 # This is a hosts file' ~/hosts
Check:
head ~/hosts