Modify read_data fuction to speedup file reading.

Using try..excpet to speed up key finding.