konstruer de data, du vil skrive i en variabel, og lav blot en skrivning til fil. det er meget mere effektivt.
$fp1 = fopen( 'obspg.txt', 'w' );
$outPut = "RETSKU\tProduct Title\tDetailed Description\tProduct Condition\tSelling Price\tAvailability\tProduct URL\tImage URL\tManufacturer Part Number\tManufacturer Name\tCategorization\tGender\tsize\tColor\n";
//retrive records from database and write to file
$result = mysqli_query($con,"SELECT * FROM `TABLE 1` ");
while($row = mysqli_fetch_array($result))
{
$outPut .= $row[`id`]."\t".$row[`title`]."\t". $row[`description`]."\t".$row[`condition`]."\t". $row[`price`]."\t".$row[`availability`]."\t".$row[`link`]."\t". $row[`image_link`]."\t".$row[`mpn`]."\t".$row[`brand`]."\t".$row[`google_product_category`]."\t".$row[`Gender`]."\t".$row[`size`]."\t".$row[`Color`]."\n";
}
fwrite( $fp1,$outPut);
fclose( $fp1 );