Fixed payload generation for bulking, included ending newline

No ending newline caused bulking to succeed for all but the last
document in the payload, without throwing an error