find out that writefile() is doubled