Reading files with certain variables specifications and writing them in on file