echo ''>logfile at the first for mode=a