Rename file and stream to to_file, to_stream and added valid? function