Ensure user is in correct group for whole write.
Pass context.
Merge pull request #2445 from ximenesuk/rebased/develop/bulk-annotations-12210

Fix permissions in bulk annotation script (rebased onto develop)