From: Leslie Viljoen Date: 2006-07-17T23:54:33+09:00 Subject: Re: First ruby code, need hint on iterator > This program has a serious flaw: only if 16 bytes are collected from the input, > a new line with hex codes is printed. If the input string has a length that is > not a multiple of 16, the remaining bytes will not be handled. > > A solution would be to duplicate the line > > out << sprintf("%08x: %-50s %s\n", offset, hex, str) I think it's ok to duplicate a single line. If you are worried about the two lines getting out of sync, put the line in a function: def printHex(out, offset, hex, str) out << sprintf("%08x: %-50s %s\n", offset, hex, str) end