What do you mean by "doesn't work". Apart from outputting 10001 values and looping 10000 times (not a problem, just won't write your last element) and the seeming pointlessness (writing the same value over and over at 10kHz - presumably this is to simplify the demo) it's not clear what shouldn't work.
Do you mean it takes much longer? Perhaps you receive a timeout error? If so, the issue is likely to be the fact that you're trying to run a loop iteration in less than 0.1ms to be able to keep up with the sample rate - you should take N points instead of 1 Point and reduce the number of iterations of the loop.