dump with lock to avoid possible concurrency issues (just in case, shouldn't be a problem
fix stupid open() not to truncate pre-existing downloaded file
added -o to output into specified location
complete internal refactoring