updated huffman algorithm (stdin/stdout)