separate digits read from stdin into groups