title: Saving data into a text file
body: <pre><code>def ConvertFile():
    FileNameIn = 'Hexdata.dat'
    HexFile = open(FileNameIn, 'r')
    for Line in HexFile:
      print (Line)
      print (Binary(Line))
    HexFile.close()
  </code></pre>
  
  <p>So far I have that, which, when the program is run, converts the Hexidecimal number in the file to binary. This is in a file called Hexdata.dat</p>
  
  <p>What I want to do is then save the binary output into a file called Binarydata.dat</p>
  
  <p>How would I approach this in code? Be aware I'm new with Python and haven't covered this properly. I've tried different bits of code but they've all been unsuccessful, as really, they're all guesses.</p>
  
  <p>I'm not asking you to solve the problem for me, but more asking how I would save the output of a program into a new text file.</p>