It probably worked correctly, but in the screenshot, you are trying to view the encrypted file a.gpg. The file a.gpg it needs to be decrypted before you can view the contents:
(you could look at a.gpg in a text editor, but would only see a string of scrambled unreadable characters.)
gpg -o <filename-for-decrypted-file> -d a.gpg
It helps to use an extension on the file you are encrypting so that when you want to decrypt it again, you (and the computer) know how to open the resulting decrypted file. sample.txt will encrypt into sample.txt.gpg. Later, when you want to decrypt this back to a normal file, it suggests the name you might use for the decrypted file (sample.txt) and the application to open it.
You wouldn't use this method to send encrypted files to someone else. That requires public and private keys and is another topic. It also uses gpg, however.