Added function to read a matrix from a file