##################################################
## Function to write to txt file using sink (instead of screen).
##################################################
printfl=function(x,doIt=FALSE,fnm=NULL) {
#x: thing to be printed
#doIt: if TRUE, print to file fnm, if FALSE, just print as usual.
#fnm: name of file to be printed to.
if(doIt) {
   sink(fnm)
   cat('\\begin{verbatim}\n')
}
print(x)
if(doIt) {
   cat('\\end{verbatim}\n')
   sink()
}
}

