Rewrite using Mechanize, add login error handle, improve perfomance by refuse write fails on disk.