You may choose to store the coding information in the same file with the compressed version, or devise some system which uses two files (one encoded; one the coding information) to represent one unencoded file.
Clearly specify in your comments what data structures (and file structures) you have chosen and why.
Your script should show the listing of an unencoded file; the encoded version; and the final, decoded version (which, hopefully matches the original).
You may assume your input file contains only lower case characters, spaces and newlines (in addition to the requisite end-of-file), if you would like.