File pointer check added