updated opening file for append instead of write