there's no function to write something to a specific line in a file, since internally a newline is just a character as any other.
instead:
// read file content, e.g. with
$lines=file($filename);
// (reads line by line into an array)
// modify the content, e.g.:
for ($i=0; $i<count($lines); $i++) {
$lines[$i] = ucwords(strtolower($lines[$i]));
}
// open file for writing
$fp=fopen($filename, 'w');
// write modified content to file
fwrite($fp, implode('', $lines));
// close file:
fclose($fp);
I hope this gives you an idea. also make sure you have read and write permission for that file.
[EDIT: sorry, mixed things up, you don't need fopen() and fclose() when you work with file(). I changed the code to correct this.]
[EDIT: more corrections needed :S, but I really hope it is correct now.]