diff --git a/yq.go b/yq.go index 458ca6ea..549cfbc2 100644 --- a/yq.go +++ b/yq.go @@ -633,11 +633,12 @@ func safelyRenameFile(from string, to string) { if copyError := copyFileContents(from, to); copyError != nil { log.Errorf("Failed copying from %v to %v", from, to) log.Error(copyError.Error()) + } else { + removeErr := os.Remove(from) + if removeErr != nil { + log.Errorf("failed removing original file: %s", from) + } } - removeErr := os.Remove(from) - if removeErr != nil { - log.Errorf("failed removing original file: %s", from) - } } }