What is $openedFile? You shouldn't be able to both iterate it in a foreach as well as write to it with fwrite.
With only 10 lines, its mucho easier than this:
Another option would be to use a random access file with an explicit maximum length for each record. Then you would simply write the data (null padded or pack()ed in binary) to the position desired. Wastes more space IMO, but would be useful if you have much larger files to work with since you can jump to any arbitrary record in the file.
$sFile = '/path/to/file.txt';
$aEntries = file($sFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
// $aEntries is now an array ordered by the lines in the file offsets 0 - 9 (10 lines)
// manipulate it as you see fit.
// put it back in
if (file_put_contents($sFile, implode(PHP_EOL, $aEntries)) !== false)
print 'File successfully written';
// all done.