Fixed output filenames.

Previously, the output filenames were generated from the input filenames
by replacing ".adg" with ".ly" anywhere in the string. Consider the
following examples:

- "test.adg" -> "test.ly" (OK)
- "test" -> "test" (overwriting input file!!!)
- "test.adg.bak" -> "test.ly.bak" (not really expected behavior)
- "test.adg.bak.adg" -> "test.ly.bak.ly" (not really expected behavior)
- "test.adging" -> "test.lying" (unexpected)
- "test.adg.2" -> "test.ly.2" (not sure if this is desirable)

The new behavior replaces ".adg" with ".ly" if it occurs at the end of
the filename. Otherwise, ".ly" is appended at to the filename. These
examples seems more reasonable:

- "test.adg" -> "test.ly"
- "test" -> "test.ly"
- "test.adg.bak" -> "test.adg.bak.ly"
- "test.adg.bak.adg" -> "test.adg.bak.ly"
- "test.adging" -> "test.adging.ly"
- "test.adg.2" -> "test.adg.2.ly" (not really expected)