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