<jupyter_start><jupyter_text>In order to have ease of access, instead of open() and close() of a file and assigning it to a new variable, you may use the syntax as below:<jupyter_code>with open('myfile.txt') as mypseudofile:
    contents = mypseudofile.read()
print(contents)
contents
with open('myfile.txt',mode='r') as mypseudofile:
    mypseudofile.read()
    mypseudofile.seek(0)
with open('myfile.txt','a') as mypseudofile:
    mypseudofile.write('This is the fifth line')
    
with open('myfile.txt','r') as t:
    contents=t.read()
    print(contents)<jupyter_output>Hello this is my first txt file through the jupyter notebook.
This is the second line.
This is obviously the third line.
My head is so creative :P
This is the fifth line
{'fraction_non_alphanumeric': 0.10228802153432032, 'fraction_numerical': 0.0013458950201884253, 'mean_word_length': 4.679389312977099, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '136788', 'license': 'Apache-2.0', 'n_tokens_mistral': 251, 'n_tokens_neox': 241, 'n_words': 89, 'path': 'InputOutput.py.ipynb', 'repo_name': 'ba-13/PythonBasics', 'size': '743'}