Insert text after the last match in a file

Based on <http://unix.stackexchange.com/q/78557/3645>.