It looks like there are two things you need to do:
Write and read a file.
encode and decode a String

Work on each part separately and then merge the code.

What questions or problems are you...