The 'file exists' logic was flawed. Use 'IF NOT EXISTS' statement instead