check rand.Read for errors