Changed read_matrix to read from files and text