Writing input to R to file