Fix symlinks being destroyed when editing them.

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

Fixes issue 2363.