Imagine you have a file
sink(\"example.txt\") data.frame(a = runif(10), b = runif(10), c = runif(10)) sink()
and would want to add some hea
In any language there is ultimately only one solution. And that is to overwrite the whole file:
contents = readAllOf("example.txt") overwrite("example.txt", header + contents )