generalize readFile to operate on any channel
rewrite matrix.go