Check the file integrity before actually saving it