Add error check if file is null or is a stream