Added periodic committing for safety if the computer or script crashes