Small fixes from the PR comments

- write the public keys in a single write
- define the .bash_profile in a variable
- fix a dry-run if-else branch