Trim the output file as opposed to delete to keep same permissions.

Fixes #14979