fixed offset of local array, added output file