This post helps to understand the basic syntax to opening a file and reading from it along with how we…