modified write.table() function