Make sure the pin mode is setup even if the file already exists.