Refactored code so that fs.readFile functions call callback functions, rather than contain all the code directly