Updated to get filename before execution.