Move assembleFile work into separate function to close open files