Fix symlinks being destroyed when editing them.

With this fix we dereference the link and edit the pointed-to file
instead.

Fixes issue 2363.
Merge pull request #791 from kacfengine/issue-2363

Fix symlinks being destroyed when editing them.