Yes, this would be one way to do it. Howerver I just tried it and it is great for reading and writting to small files, but when it comes to a file contaning 1 million lines, PHP uses 180Mb's memory and a time of 20++ seconds just to read the file!
I'm looking for a more efficient way to do this. However, thank you...