Writing code to open file