Look at ?paste for (j in 1:10) { write.table(j, file=paste("haplo.txt", j, sep="."), row.names=F, col.names=F, append=F, quote=F) } BTW, there have been many similar posts like this in the past. They are easily found using the search function at http://cran.r-project.org/search.html HTH, Andy