<?php $file = file("user.txt"); $a = 0;while ($a != sizeof($file)){ $str = $file[$a]; $sub = substr($str, 0, 6); $f = fopen("out.txt", "a"); fwrite($f, $sub."\r\n"); fclose($f); $a++;}