Is there anyway to retain the Realm username in a variable?

I'd like to take data submitted by a user and retain it to a file specified by user.

Thanks.