<?php $fp = fopen('file.txt', 'r'); $w = fopen('file_result.txt', 'a+'); while(!feof($fp)) { $str = fgets ($fp, 1024); if (trim($str) != '') { list($a, $b) = explode('|', $str); fwrite($w, trim($a)."|".trim($b)."\n"); } } fclose($fp); fclose($w); ?>