moving `gitCodeReference` closer to where it is used.
updating safe file opening function
handle lines that are not empty, but still are less that the clip lenght
slightly better error propagation