add -l option to specify the beep length
print periods in write_loop if it is in debug mode