Something's wrong with the inner loop. In your script, y will be eventually assigned the same as x. I assume the results will be the first file has the first 1% of the data, the second has the first 2%,...
Actually you may not need the inner loop at all. Consider the following code: