Improve duplicate project name resolution
Now the bundle name is added also on the first bundle, not only the second
bundle.
Improve encoding detection if there is a problem at the end of the file