Added file writing in lcr function.