updated file reading codes