Numbers written to file instead of kept in arrays.

This avoids huge memory problems for big N.