Use Chef::Util:FileEdit instead of grep/append