Added func to write credentials to a file.