# Doesn't open yet
tmp <- tempfile()
writer <- file_writer(tmp)
# Now it opens
writer(charToRaw("Hello!\n"))
writer(charToRaw("How are you?\n"))
# Close it!
writer(charToRaw("All done!\n"), close = TRUE)
# Check it worked
readLines(tmp)
Run the code above in your browser using DataLab