added some debug code, to see why it stops working when you change the parameters in fread and fwrite