Add support for using both match and after

Previously we were running "match" handler ignoring "after" param.
This patch enables us to use both "match" and "after" resource
parameters: if "match" is found, then we simply replace the line,
if it's not found and we have "after", then we add lines after the
specified pattern. If "match" and "after" not found, then we just
append the line.