I need to add the following line to the end of a config file:
Just keep it simple :)
grep + echo should suffice:
grep -q -F 'include "/configs/projectname.conf"' foo.bar || echo 'include "/configs/projectname.conf"' >> foo.bar
Edit: incorporated @Cerin suggestion.
NOTE: for "editors" changing my answer: if you have an alternative solution give your own answer! Editing is intended for clarifying, formatting, better English and so on! Don't change the answer given by others! (thank you)