Fixed Windows compatibility issues with newlines and file renaming