SERVER-12977 disallow empty write batches

Also fix shell batch processing to avoid extra empty batches.
(cherry picked from commit b5756056a7b5acba550a7d31a587f3a5b7651e00)