In write_xyz: Added closing the XYZ file one it was written