Added function to open file by id + try / except when writing index file