import os import requests cwd = os.getcwd() print('Current working directory is: ', cwd) res = requests.get('https://automatetheboringstuff.com/files/rj.txt') res.raise_for_status() playFile = open(cwd + '\\web-scraping\\files\\RomeoAndJuli.txt', 'wb') for chunk in res.iter_content(10000): playFile.write(chunk) playFile.close()