def read_matrix(filename):
    """ Reads a file containing integers to a matrix(list of lists). """
    digits = []

    with open(filename) as f:
        for line in f.readlines():
            ints = [int(n) for n in line.split()]
            digits.append(ints)
    return digits