I have a polygon file buffer_stands.shp with 20 features and I have a line file OSMroads.geojson with 9 features.

I expected the script to loop through the buffers and print out for each buffer loop the the point count of each of the OSMroads. I know it doesn't sound useful, but the script is a simplification of a bigger script.

The outer loop loops all the way through. But the inner loop only loops once. What is causing that and how can I fix it?

Can you explain a bit more about your data, and what you expect the code to do (in words, at a functional level, not at a code level)? My guess is that there is only one feature in the roads GeoJSON, but since you haven't shown us the data, its difficult to say.
– BradHardsNov 6 '13 at 23:02

I added some more information. In the roads GeoJSON are nine features.
– ustroetzNov 6 '13 at 23:13

OK, I see the problem. The problem is that the roads layer has been "read to the end" already. You need to reset / re-open it, or perhaps just store it in a local list
– BradHardsNov 6 '13 at 23:30

Moving the ogr.Open and GetLayer part inside the outer loop fixed the problem. Thanks for pointing out Fiona. I will look into it, since opening up the datasource each loop will slow down the script quite a bit.
– ustroetzNov 6 '13 at 23:17