makes code more efficient, fixes #5

outputs to file while reading file
makes convert function simpler
reads file by character instead of by line