writes out to file successfully