finished read_file function