cleaned up file opening and frame header detection.