Changed a few links and fixed file writing errors
Added error message for failure to write to database