Updated code for file reading