Don't write empty indexes

Change-Id: I94a394fd940b34a6654cc0f8ef841c191457cbf6