Move read file section to a function

Move it to initialized function.