Fixed bug in writing out matrix declaration