Reorder things a bit: open logger FIRST, and dont use puts.