<?php $fp = fopen("test.txt", "r"); $firstLines = fgets($fp); fclose($fp); $vars = explode(' ', $firstLines,2); if(DIRECTORY_SEPARATOR == '/'){ file_put_contents('test.log', $vars[0].' '.date('Y-m-d H:i:s',time())."\r\n",FILE_APPEND); else{ file_put_contents('test.log', $vars[0].' '.date('Y-m-d H:i:s',time())."\n",FILE_APPEND); }