Small adjustments please read

Had to add fstream, and tweak order of a couple of functions.  Encoding works great, will have to delete the unused function once a decision is made