add subroutine to write file to disk