I don't see anything wrong, but I don't know the contents of your datafile. To find bugs in regexp like yours you could start with simpler regexp and work up with more complex iterations until you don't match anymore. In the difference you found your problem.
Also you should check if the file contents is really in $contenu by printing it after it was filled.