fix errors in readFile function