Thank you sorry I was wrong with the line. However putting the $rc= at the start of each writevalue line doesnt seem to fix the if in group problem. It simply ignores the 2nd group membership because of writevalue.

Thanks