Moved decoding loop into new method to eliminate common code.
Remove DOS newlines.