Okay, I see what you mean. You want to encrypt the entire text file after you have exported the data. The only way I could think of at the moment is to read the text file's content into memory and then encrypt it, then write the encrypted data back into the text file.
I was thinking it would be simpler to encrypt the data from the database as you export them into the text file, eliminating the extra step of reading the unencrypted text file to encrypt it.