I changed the check before close() the file (because before if the file wasn't open it would still try to close() it which seg fault).
But then I realised if the first file succeeded to be opened then it wouldn't close it so I changed the check to make it close either if the first or second try succeeded
I changed the check before close() the file (because before if the file wasn't open it would still try to close() it which seg fault). But then I realised if the first file succeeded to be opened then it wouldn't close it so I changed the check to make it close either if the first or second try succeeded