Fix spaces
Add argument for the charset
Make all vars local
Reformat
Use better random algorythim, honor eof