Because the file was successfully renamed from File, the call to file:delete(File) is unnecessary and will always fail with {error, enoent}.