dont use fseek/ftell if file is NULL