updated readFile method to prevent file not found error.