Fixed variable scope issue of read_c and read_k