Fix iconv detection
Remove local variables from generated script to avoid infinite recursion when writing the package