move fp == null inside detectfileoperation.