Notice: fwrite(): write of 320 bytes failed with errno=22 Invalid argument