added outfile, startindex, sleeptime arguments