Change to use os.open to avoid visible mode change