Fix import order
Move imports to the top of the file
Handle ENOENT when deleting task logs
Simplify log message, use logger for formatting
Don't use built-in name file for variable name