When the number of bits, in this case 4096, comes after the option where to put the file (-out), openssl seems to output meaningful data. That is the correct way. The script is wrong, because the script puts the option after the numbits, be it 512, 2048 or 4096.
This is wrong:
openssl dhparam...