Moved groups assignment out of useradd to avoid errors when the group is the same as the default user group
check whether a usergroup is set explicitly as part of the groups parameter and set it as default group on systems with usergroups enabled
added try..except around file open call as this will fail on some systems.
In such cases it is assumed usergroups are not enabled.
Merge pull request #4077 from grischa/useradd

Useradd stability improvements