Installed.txt is created in /install/cache/

The installed.txt file is created in /install/cache and not /install. Which means it will already be deleted at the first line.