Split file creating into separate functions, and added timing.