added function readfromfile for matrix 1xn