fixed check for file-like object