Adding check for empty logs before trying to flush