title: how to insert a youtube link in text file using python
body: <blockquote>
  <p>I am basically building a CLI application where im asking user file path for text file and some youtube links as to insert it in that particular text file
  and then with random selection , im reading the youtube link and opening via web browser library
  but im getting a error , here</p>
  </blockquote>
  <pre><code>    return callback(**use_params)  # type: ignore
    File &quot;d:\useless folder(only for coding use)\docx folder\for_cmd.py&quot;, line 18, in youtube_selecter
      file = open_file.readlines()
  AttributeError: 'NoneType' object has no attribute 'readlines'
  </code></pre>
  <blockquote>
  <p>my code is below</p>
  </blockquote>
  <pre><code>import webbrowser
  import typer
  import os 
  import random
  
  
  
  app = typer.Typer()
  @app.command()
  def youtube_selecter():
    ask_filepath = None
    while not os.path.exists(ask_filepath):
      ask_filepath = input(&quot;enter a empty file filepath for saving youtube links&quot;)
    ask_youtube_link = None
    while ask_youtube_link != &quot;quit&quot;:
      ask_youtube_link = input(&quot;enter youtube link&quot;)
      with open(ask_filepath,&quot;r+&quot;) as f:
        file = f.readlines()
        f.write(ask_youtube_link + &quot;\n&quot;)
      if ask_youtube_link == &quot;quit&quot;:
        break
    ask_user = input(&quot;do you want to read the file&quot;)
    if ask_user == &quot;yes&quot;:
      print(file)
    else:
      print(&quot;ok&quot;)
    random_choice = random.choices(f)
    while ask_user != &quot;yes&quot;:
      ask_user = input(f&quot;do you want to view {random_choice}&quot;)
      if ask_user == &quot;yes&quot;:
        open = webbrowser.open(random_choice)
  if __name__ == &quot;__main__&quot;:
    app()
  </code></pre>
  <blockquote>
  <p>so can help to solve this issue?</p>
  </blockquote>
  <blockquote>
  <p>you can copy/paste and check it
  you can copy/paste and check it</p>
  </blockquote>